Stoudemire scored 25 points but also had five turnovers for the Knicks, who've lost four in a row. The 6-foot-6 Hayes is 4 inches shorter than Stoudemire, but carefully studied his tendencies on video to get ready for the matchup.
It paid off, especially in the fourth quarter, when Stoudemire went 3-for-8 from the field and lost the ball to Hayes on consecutive possessions.
"It doesn't matter who it is, my preparation will always help me going into a game," Hayes said. "I watch film. Not only do I watch film, but I watch a lot of basketball. I've watched him play and I understand what he's good at. I just had to make it tough for him."
Stoudemire went 11-for-21 from the field and attempted only six free throws, making three.
"He did a good job out there," Stoudemire said of Hayes. "He does a great job of creating contact and then being able to strip the ball."
The Rockets had developed a recent pattern of blowing fourth-quarter leads at home, but now they've held off opponents' rallies for two straight games.
"No use in bringing it up," forward Shane Battier said. "We just wanted to stay solid and continue to do the things we'd done for three quarters."
The Knicks shot 42 percent (35-of-83), scored only 39 points after halftime and were held almost 19 points under their league-leading scoring average (107.5 per game).
New York looks for Stoudemire inside on almost every possession, and Hayes was relieved when the Knicks started looking for other options in the final quarter.
"They started to drift away from him a little bit, and I needed a break," Hayes said. "He's such a great player, he's such a hard guard. When every play is designed for him, and you've got that call to match up against him, you better bring your lunch pail."
The Rockets shot 22 percent from 3-point range over their previous four home games, but went 4-for-8 from beyond the arc in the first quarter to build a 36-27 lead.
Houston's reserves stretched the lead to 14 after the Knicks missed seven of their first eight shots in the second quarter. But after the crisp start, Houston missed seven of its next eight 3-point attempts, and New York went on a 10-2 run to cut the deficit to 45-39.
Houston's starters returned and built the lead to 60-50 by halftime. The Knicks went 4-for-13 from 3-point range in the first half.
The Rockets' 3-point shooting tapered off in the third quarter, but they preserved a healthy lead by attacking inside. Houston scored 14 points in the paint in the first eight minutes of the period and led by nine.
"We didn't bring the effort defensively, from the start," Stoudemire said. "They pretty much got what they wanted."
Houston had a double-digit lead in the fourth quarter for the fifth time in its past six home games. But Toney Douglas opened the period with a drive, and Danilo Gallinari and Douglas hit consecutive 3s to quickly pull New York within five.
Budinger and Brooks scored on drives to stall New York's surge. Stoudemire coughed up back-to-back turnovers to Hayes, and Martin's 3-pointer from the corner -- his first of the game in nine attempts -- put Houston up 96-83 with 5:30 left.
Knicks coach Mike D'Antoni was surprised to hear that Nets owner Mikhail Prokhorov pulled out of his pursuit of Carmelo Anthony, but said he doesn't think it affects his team. "They do their business, we do our business," D'Antoni said. Anthony's reported preference is to play for the Knicks, but they've been unable to put together a package that rivaled the one the Nets offered Denver. "It doesn't matter if I'm concerned or not," D'Antoni said. "We do our business, we go. That's on one side, and basketball's on the other. We stick on the basketball side and we do everything we can to make us a winner every night and see what happens." ... The Rockets reached 60 points in a half for the 16th time this season. ... Stoudemire has scored at least 20 points in 26 consecutive games, the third-longest streak in franchise history.