James Harden scored 37 points and Aaron Brooks made a pair of free throws with 17 seconds left to lift the Houston Rockets to a 102-100 win over the Knicks on Friday night.
The Knicks had a chance to tie it at the end of the game, but Iman Shumpert missed a shot before Andrea Bargnani grabbed a rebound and dished it to Beno Udrih, whose running jump shot rolled in and out of the basket at the buzzer.
Several Knicks put their hands on their heads in disbelief as they watched the ball spin out.
Udrih and J.R. Smith both missed 3-pointers for the Knicks with under a minute remaining. Brooks grabbed the rebound on the second one and was fouled by Udrih to set up the game-winning free throws.
Harden scored a season-high 38 points in Houston's last game.
Shumpert, who scored a career-high 27 Thursday night, led the Knicks with 26 and Carmelo Anthony added 25.
Anthony returned on Thursday night after missing three games with a sprained left ankle and tweaked it late in that win. He was still struggling with it on Friday night, and winced almost every time he landed after jumping in the second half.
Shumpert hit a 3-pointer to cut the lead to two points before Tyson Chandler hit two free throws to tie it at 100 with 1:02 left. Chandler finished with 13 points and 11 rebounds.
Houston used a big run to start the fourth quarter and erase an eight-point deficit. The teams exchanged leads several times after that, but neither team led by more than a basket in the quarter before Harden scored five straight points to make it 100-95 with 2:23 remaining.
Chandler Parsons added 17 points and 11 rebounds for Houston, Dwight Howard had 15 points and Jeremy Lin scored 14 against his former team.
The Rockets opened the final period with a 10-1 run to take an 83-82 lead with about nine minutes remaining. Francisco Garcia and Aaron Brooke made back-to-back 3-pointers to cap the run and take advantage of Anthony starting the quarter on the bench.
Harden scored 11 points, powered by three 3-pointers, in the opening minutes of the second half to stretch Houston's lead to 61-56 with about eight minutes left in the third quarter.
Anthony, who scored 45 points against Houston earlier this season, responded after that by making the first four points of an 8-0 run by New York to put the Knicks up 64-61.
The game was tied at 66-all when New York scored seven straight points to regain the lead 73-66.
New York led 81-73 entering the fourth quarter thanks in part to 13 points by Shumpert in the third.
The Knicks led by one with about 7½ minutes remaining in the second quarter when Houston used a 10-2 run to take a 39-32 lead.
Chandler received a technical foul in that span when he got tangled up with Howard and swung an elbow. Lin then made a nifty reverse layup and the ensuing free throw and Houston capped the run with an alley-oop dunk from Harden to Terrence Jones.
New York got going after that, using an 11-2 spurt, with consecutive 3-pointers from Anthony, to regain a 43-41 lead.
Parsons made a pair of free throws with seconds left in the second quarter to lead 48-47 at halftime.