McGrady scored 39 points as the Rockets won their fifth straight and clinched home-court advantage in the first round of the playoffs.
Houston also snapped a six-game losing streak to Phoenix and secured its best record since 1997. The Rockets will open the playoffs at home against Utah next weekend. McGrady has never won a playoff series in five tries, but his team will have the extra home game for the first time.
"This is one of the greatest accomplishments of my career personally," McGrady said.
McGrady also had 11 rebounds and nine assists and Yao Ming added 34 points and nine rebounds. When the final buzzer sounded, the Rockets celebrated at midcourt as the capacity crowd stood and roared.
"It is huge," said Yao. "We were so excited when the clock was running to zero. It feels like winning a playoff series."
After the celebration, McGrady reflected on the season that started with a recurrence of his back problems. He missed seven games in December, then returned just before Yao broke his right leg. Yao missed 32 games, but McGrady helped the Rockets to a 20-12 record without him.
"Yao going down for 2½ months put us in a situation to either move forward or really do something special in terms of keeping our head above water," McGrady said. "I didn't want that to happen. I took my game to another level, the guys stepped up and played extremely well."
Amare Stoudemire scored 30 points and Shawn Marion added 27 for the Suns, who used their starters most of the game even though they had already clinched the No. 2 seed in the West. Steve Nash added 15 points and 15 assists.
"We want to win every game and keep playing well into the playoffs," said Phoenix coach Mike D'Antoni. "We're having fun playing and we'll keep playing that way."
The game had playoff intensity from the start, and despite building a double-digit lead midway through the fourth quarter, the Rockets had to sweat out their first victory over the Suns in Houston since November 2003.
The Rockets led 118-108, but Leandro Barbosa started the Suns' last-ditch rally with a layup and a 3-pointer. Nash then intercepted a bad pass by Luther Head and found Stoudemire for a dunk to trim Houston's lead to 118-115 with 48.5 seconds left.
McGrady missed a 3-pointer and the Suns rebounded with one last chance to tie. Nash missed a 3-pointer with 6.4 seconds left, but the ball ricocheted off Head and out of bounds.
Stoudemire missed another 3-pointer and Marion tipped it in, but that only cut the deficit to one. Rafer Alston was fouled and hit two free throws for the final margin.
McGrady hit 14 of 31 shots and missed his first triple-double since 2003 by one assist. Yao was 14 of 20 and 6-for-6 from the free throw line.
"Tracy played a great all-around game," Marion said. "When Yao got going, it was really hard to stop the tandem."
McGrady scored 25 points in the fast-paced first half, smoothly sinking jumpers from every angle. Every time McGrady scored, the Suns answered.
McGrady also had five assists in the half, the last to Yao for a hook shot with 5.2 seconds left before the break. Yao blocked a shot by Stoudemire in the closing seconds, but Stoudemire got the rebound and threw in a mid-range shot at the buzzer to cut Houston's lead to 56-54.
Stoudemire was 8-for-12 and scored 20 points in the opening half.
McGrady came up with the shot of the night a minute into the second half, driving past Stoudemire for an up-and-under reverse layup. Unfazed, Stoudemire responded with a mid-range jumper at the other end.
McGrady sank his second 3-pointer and Yao converted a three-point play to start a 19-4 Rockets run that broke a 66-66 tie.
The Suns rallied with Nash on the bench. Marion scored twice inside and James Jones hit a 3-pointer from the wing to cut Houston's lead to 93-86 with just under 10 minutes left.
Nash and Stoudemire returned after long rests with 7:03 left, but Head hit a 3-pointer and Yao scored inside over the next minute to push the lead back into double-digits.
The Suns mustered one more rally in the final minutes, but couldn't complete their second straight regular-season sweep of Houston.
- The Rockets honored retiring general manager Carroll Dawson at halftime. Dawson spent 27 years with the Rockets, the last 11 as GM. "I look forward to many years in the stands hollering for these guys," Dawson told the crowd. During timeouts, the scoreboard showed videotaped messages to Dawson from NBA commissioner David Stern, Jerry West, Larry Bird, Hakeem Olajuwon and Rudy Tomjanovich.
- Phoenix can match a franchise record for regular-season wins with a victory over the Clippers on Tuesday.
- The Rockets reached their highest victory total since going 57-25 in 1996-97.
- Houston Texans defensive end Mario Williams had a courtside seat.