Bryant scored 53 points and brought the Los Angeles Lakers back from a late 12-point deficit in regulation, but the Rockets beat them 107-104 in overtime Friday night.
Yao had 39 points and McGrady added 30, enough to overcome Bryant's fifth 50-point outing in the last seven games.
"He's amazing," said Houston's Rafer Alston, who made a pair of free throws with 14 seconds left to cap the scoring.
Rockets coach Jeff Van Gundy said: "I was fine on our defense on Bryant. There's only so much you can do."
Bryant, who had made a dramatic 3-pointer late in regulation to tie the game at 95 and send it into regulation, bounced another shot from beyond the arc off the rim and the Rockets rebounded as the overtime ended.
With Los Angeles trailing 88-76, Bryant took charge, scoring 17 points in the final 4:07 of regulation.
"My shots were going long. I took a few deep breaths and regrouped," said Bryant, who scored 25 of the Lakers' final 28 points and finished 19-for-44 from the field.
Yao intentionally fouled Kwame Brown with 16 seconds remaining in regulation, and Brown missed both free throws. But Bryant got the long rebound off to the left and made a fallaway 3-pointer from the corner to tie it at 95.
McGrady then missed a jumper, with Bryant guarding him, as time ran out in regulation.
Los Angeles was up 104-100 with 1:03 remaining in overtime, but Bryant fouled McGrady beyond the 3-point line and McGrady made three free throws.
"That was a big play for us because we were down four and we were fortunate enough to get three free throws and knock all of them down," McGrady said.
Yao scored on a layup with 23 seconds left, then Alston made the two free throws.
Yao, who had 11 rebounds, went 17-for-21 from the free throw line and 11-for-18 from the floor. McGrady scored 15 points from the line, and had 10 assists. But he was 7-for-24 from the floor.
"Obviously, Tracy was struggling from the floor," Van Gundy said. "Yao came through in a big way."
Alston added 19 points.
Bryant scored 50 or more for the eighth time this season and 19th time in his career. He was coming off a 23-point game in an 88-86 loss to Memphis. He had scored at least 40 in the previous five games, including 50 or more in the first four. He scored 65 in one of those and 60 in another.
Lamar Odom had 16 points and 17 rebounds for the Lakers before fouling out with 15 seconds left in overtime.
Chuck Hayes had 14 rebounds and six points for Houston.
The Rockets were up 75-67 heading into the fourth quarter after leading 53-48 at halftime.
- Lakers coach Phil Jackson said playing 82 regular-season games causes injuries, and suggested that the NBA consider cutting back. "Our league has to discuss the number of games we play. Eighty-two games is too many," he said before the game. "They train year-round. During the season they play 3 1/2 games a week or seven games in 14 days. They play when they are fatigued and that's when they get hurt. I've cut practices to 45 minutes. I've never had a team with this many injuries. Guys need time to recharge and rehab."
- Houston held Bryant to 20 points on 6-for-18 shooting, in the Rockets' 102-77 win on Jan. 10.