Yao has been battling flu-like symptoms recently and though it showed much of the game, as he had a season-high eight turnovers.
Seven of those through the first three quarters.
"I had some problems breathing," Yao said. "I felt like I had a lot of fluid in my lungs and in my nose.
"But I know in the fourth quarter you can't make mistakes. I had seven turnovers and I didn't want to get any more. I just wanted to put the ball in the hoop and get the lead and go home and sleep."
Coach Rick Adelman praised his team's perseverance.
"It was a tough game for both teams," Adelman said. "But our guys stayed with it defensively and in the fourth quarter we just tried to go through Yao."
Tracy McGrady missed his second straight game with left knee tendinitis. He is day-to-day.
"We talked about a way to win without one of our key players," said Rafer Alston, who had 18 points and five assists. "We haven't done that this year when Tracy or I were out. So we just want to finally show we have some depth."
Bonzi Wells had 13 points and 11 rebounds as Houston won its second straight and third in four games.
Chris Bosh led the Raptors with 19 points. Jamario Moon and Jose Calderon each scored 11 as Toronto lost for the fourth time in five games. Calderon, who is sixth in the NBA with 7.9 assists per game, had 10.
"We're trying to figure out why we're not scoring," coach Sam Mitchell said. "We normally are top five in scoring but we have to try and get some easy baskets. All of our baskets are grind-out baskets and we're working too hard."
Bosh and Mitchell had a discussion after the game.
"We had to clear some things up and Coach and I came to a middle ground," Bosh said. "I hate to lose and he hates to lose and we just talked about it.
"We need to do a better job of taking it at teams. If we start early and play aggressive, Coach and I feel we can do a better job."
Yao scored eight in the fourth quarter, including four straight free throws to give Houston an 85-75 lead with 2:29 to play.
With Yao scoring nine and Alston eight in the third quarter, the Rockets led by seven with 2:52 left in the period. But Bosh had eight points, and Calderon and Moon five apiece to pull the Raptors to 68-64 after three quarters.
Both teams struggled in the first quarter, with Houston hitting only 33 percent from the field and Toronto going 7-of-24 (29 percent). They were tied at 19 heading to the second.
The game remained back and forth until Toronto went on a 9-1 run to take a 40-34 lead with 1:36 left in the second quarter. But Houston scored five points the final 5 seconds on Alston's 3-pointer, and a steal and layup by Shane Battier to knot it at 40 at halftime.
It was the fifth game this season McGrady has missed due to injury. The Rockets are 2-3 without McGrady this season and 13-42 without him in his four seasons in Houston. ... Wells made his second straight start in place of McGrady and his third start overall. ... The Raptors, who lead the NBA in 3-point shooting at .421, didn't attempt a 3-pointer the first quarter and didn't make one until Carlos Delfino hit one with 2:55 left in the half. They hit just 2-of-10 for the night. ... Toronto, which beat San Antonio 83-73 Friday, is 4-5 in the second game of back-to-backs this season. Houston, which defeated Memphis 103-83 Friday, is 6-12.