Brooks scored a career-high 30 points and drove past O'Neal for the winning basket in the Rockets' 116-112 win over the Phoenix Suns. Nash shook off a poor first half to score a season-high 32 points, but the Suns dropped their fourth straight road game.
O'Neal scored 17 on his 37th birthday for Phoenix, which slipped three games behind Dallas in the race for the No. 8 playoff spot in the West. The Rockets moved a half-game ahead of New Orleans for fourth place in the conference.
"We really needed this victory," Brooks said. "In the West, everything is so close, when you play teams in the playoff hunt, you've got to really bring it to them."
The Rockets led most of the way, but Nash made his fourth 3-pointer with 30 seconds left to tie it at 112.
With the shot clock running down for the Rockets, Yao set a high screen for the 6-foot Brooks, who beat O'Neal to the basket with an underhanded layup with 7.3 seconds left.
"That was a little bit too close," Brooks said. "I barely got it past him. I laid it up and I was relieved."
Nash missed a 3-pointer off the front of the rim with Yao running at him on the Suns' final play. Ron Artest rebounded and made two free throws with 0.3 seconds left.
"I felt good, I had a good look at it and it was straight on," Nash said of his final shot. "I just didn't make it."
Nash went 1-for-10 from the field in the first half and said he was bothered by the sprained right ankle that kept him out three games.
He went 13-for-17 with nine assists in the second half, single-handedly keeping Phoenix close.
Brooks became Houston's full-time point guard two weeks ago, when Rafer Alston was traded to Orlando. He scored 17 in the second half and nine in the final quarter, another big step in his development.
"It gives you a little more confidence to know you can finish," Brooks said. "I'm just happy we won. That's the most important thing."
Nash stopped into the Rockets' locker room after the game to talk to Yao, his close friend. He didn't speak to Brooks, but had high praise for the second-year guard.
"He killed us and made a couple of big plays at the end of the game," Nash said. "He's really turning into a terrific guard and the Rockets are going to have a guy for a long time who can handle this position."
Artest added 21 points and Yao had 15 points, 13 rebounds and a season-high six assists for the Rockets, who've won 11 straight home games.
The talk leading up to Friday's game centered on the matchup between Yao and O'Neal, not the opposing point guards.
Yao blocked O'Neal's first shot 20 seconds into the game, but Luis Scola carried Houston early, grabbing five rebounds and scoring eight points in the first 8 minutes.
Robin Lopez replaced O'Neal with 4:36 left in the first quarter and Yao blocked Lopez's first shot, part of the Suns' 3-for-14 start.
The Rockets led 23-18 after the first quarter, and Nash and Leandro Barbosa made 3-pointers early in the second quarter to give the Suns their first lead, while O'Neal struggled. He missed 4 of his first 6 shots and lost the ball to 6-foot Kyle Lowry.
O'Neal sent Yao to the floor on an offensive rebound and dunked to cut Houston's lead to 37-34, but the Rockets answered with a 7-0 burst to stretch the lead to 10.
Houston led 56-46 at the break, mostly due to Nash's quiet first half.
"He was just feeling us out a little bit," Brooks said with a smile. "The shots he was getting, he typically makes. We were just lucky in the first half that he was off a little bit."
With O'Neal setting screens for him early in the third quarter, Nash scored 13 points to help the Suns cut the deficit to three. Louis Amundson finished a fast break with a layup and drove for another basket to tie it at 75-all.
The Rockets led 81-76 after three quarters, and O'Neal and Yao were back in the game for the start of the fourth.
O'Neal went out for a rest with 7:41 left and Houston ahead 89-82. The Suns double-teamed Yao with O'Neal on the bench, and he found Carl Landry open for a dunk for his sixth assist.
The Rockets led 94-88 when O'Neal returned near the 6-minute mark. But the game turned into a 3-point shooting duel, with 3s by Nash and Matt Barnes matched by Brooks and Artest to keep the Rockets ahead by six.
The Suns went 12-for-28 from 3-point range, the most makes by a Houston opponent this season. ... Scola had 15 points and 11 rebounds. He has nine double-doubles in his past 11 games. ... Suns coach Alvin Gentry presented O'Neal with a chocolate birthday cake after Friday morning's shootaround. Goran Dragic then sang "Happy Birthday" in his native Slovenian. ... Barbosa scored 24 for the Suns.
Fantasy basketball daily notes for Tuesday
Your essential daily recap of last night's NBA action, and roster tips for Tuesday night's matchups.
2022 NBA draft top 100 and stock watch: Who is on the move after Feast Week?
The Chet Holmgren vs. Paolo Banchero battle was but one matchup NBA evaluators had eyes on last week.
Chris Paul, Devin Booker and the Phoenix Suns' master class in clutch-time dominance
The NBA's most clutch team is led by two of the NBA's most clutch players. No wonder the Suns have won 16 straight games.