"It's a huge sigh of relief," Harden said. "We found a way. It wasn't pretty. It wasn't the prettiest win, but at the end of the night a win is all that matters."
Harden scored 37 points and Aaron Brooks made a pair of free throws with 17 seconds left to lift the Rockets to a 102-100 victory.
The Knicks had a chance to tie it at the end, 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.
Smith admitted after the game that he made a mistake in taking his shot, which came with 19.9 seconds remaining.
"Honestly I thought we were down two when I shot the ball," Smith said. "I started hearing Tyson (Chandler) say 'No, no, no don't take the shot.' But at that point it was already released ... it was just bad basketball IQ by me."
Carmelo Anthony couldn't believe they had another play where they should have held the ball instead of taking an ill-advised shot. In a game last month against Milwaukee, Bargnani jacked up a 3-point attempt with 11.9 seconds left and New York up by two points in overtime. The Bucks made a shot on the other end to force a second overtime, but the Knicks were able to rebound for a double-overtime win in that one.
"Yeah, yeah, it was kind of like deja vu," Anthony said when asked if that play reminded him of Smith's shot.
New York coach Mike Woodson said Smith's miss was just one of many opportunities they didn't take advantage of Friday night.
"We had our shots and I think we compounded it too by fouling instead of making them go through our defense," he said.
Shumpert, who scored a career-high 27 Thursday night, led the Knicks with 26 and 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 Friday night, and winced almost every time he landed after jumping in the second half.
"I think it was just the back-to-back and not giving it a chance to rest," Anthony said. "It was just aching at times, at moments throughout the game."
Shumpert, who was 6 for 6 on 3s, hit a 3-pointer to cut the lead to two points before 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.
The Rockets opened the final period with a 10-1 run to take an 83-82 lead with about nine minutes remaining.
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 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.
Singer Paul Simon, who will perform with Sting at the Toyota Center in February, attended the game. ... Knicks F Kenyon Martin has a sore left ankle and did not dress for the game. ... Houston C Omer Asik missed his 16th straight game right thigh and knee injuries.
Would David Fizdale be a good hire for the Grizzlies? Will the team keep free agent Mike Conley? Our crew forecasts the future for Memphis.
David Fizdale, an assistant with the Heat, has been offered the head-coaching job with the Grizzlies and the sides are working on a contract, according to ESPN and a Vertical report.
Check out top NBA playoff moments from the past week, including the Toronto Raptors' victory over the Cleveland Cavaliers to tie their series 2-2 and the Oklahoma City Thunder's victory to claim a 3-1 lead in their series with the Golden State Warriors.