McGrady had 25 points and nine assists, and the Rockets beat Boston 111-80 Wednesday night to snap the Celtics' four-game winning streak.
Six players scored in double figures for the Rockets, who ended a two-game skid and won for just the second time in six games. Shane Battier had 15 points, and Chuck Hayes tied a career high with 14 points and added 11 rebounds.
Yao, playing for the second time since missing 32 games with a fracture in his right leg, had 11 points and five rebounds for Houston.
"A lot is riding on my shoulders to go out and try to lead this team and have him catch up to us," McGrady said. "It's going to be a slow process for him to really catch up to us and get in game shape. But it's a great thing to have him back -- it will relieve some of the pressure off of me offensively and just give ourselves a low-post presence."
The Rockets went 20-12 in Yao's absence, with McGrady taking on more of an offensive role to compensate for Yao's 25.5 points per game. McGrady had 15 of his 17 30-point games in Yao's absence, and handed out at least 10 assists four times during that stretch.
In his first game back, a 91-85 loss to Cleveland on Monday, Yao had 16 points on 5-of-15 shooting, 11 rebounds and five turnovers in 27 minutes. He shot 4-of-9 against Boston, but got into early foul trouble and played just 19 minutes.
"The last game I had turnover trouble," Yao said. "Foul trouble is what put me on the bench today. I think it's still because of speed. If I can get a little bit quicker to get to my positions to stop the ball, I can (stop) my fouls. For the first quarter, I felt much better for conditioning."
The Rockets led 30-22 after the first quarter, then started the second on an 11-2 run to blow it open early.
Pierce scored eight straight points to cut the deficit to 69-57 midway through the third quarter, but Battier made three 3-pointers during a 17-4 run that helped Houston pull away again.
"We gave up too many 3s," Pierce said. "It really hurt us. When a team is shooting that well and gets a big lead, it's tough to come back."
Houston avenged a 77-72 loss to Boston on Feb. 26 in which the Rockets set a season low in points. Besides Yao's absence, McGrady missed that game with the flu.
With both superstars back in the lineup, the Rockets were hardly challenged this time.
Houston shot 51 percent, matching its point total from the loss to Boston with 7:07 left in the third quarter. The Rockets went 15-of-28 from beyond the 3-point arc and handed Boston its worst loss of the season.
"They played with an unbelievable purpose," Celtics coach Doc Rivers said. "They're a better team, and that's where we want to be someday. Obviously, we're not there yet."
Houston led 93-68 after the third quarter, and Pierce sat out the entire fourth quarter.
Jefferson also sat out most of the fourth with a sore right foot, but said he could have played had it been close.
The Rockets forced 21 turnovers. ... Houston C Dikembe Mutombo had seven rebounds and two blocks off the bench. ... Boston F Ryan Gomes sat out the second half with a sore left foot. ... Celtics G Delonte West left in the third quarter with a mild concussion and did not return.