The Rockets had trouble putting away the Suns, who have won just 16 games this season, and trailed for much of the night as they struggled from long-range, making just 11 of 40 3-pointers.
It’s Houston’s franchise-record 10th straight win over the Suns, and the Rockets have won 10 of their last 11 games overall.
They were up by 2 after two free throws by Harden with about four minutes to go. He hit his head on the court after being knocked down on a hard foul by Deandre Ayton about 90 seconds after that, but got up and made two more free throws.
Mikal Bridges missed a 3 for the Suns and Harden added a jumper on the other end to make it 102-96 with about two minutes remaining.
But Devin Booker made the next four points to get Phoenix within two points at 102-100 about a minute later.
Danuel House padded the lead with a 3-pointer after that, but Booker made a jump shot to cut it to 105-102.
A turnover by Harden gave the Suns the ball back. But Josh Jackson missed two free throws with 24.6 seconds left and Harden made one of two free throws with 11.1 seconds remaining to make it 106-102.
Booker missed a 3 and Harden made two more free throws to secure the victory.
Booker had 29 points for the Suns, who lost their second in a row.
The Suns led by 2 to start the fourth and had a 3-point lead with about nine minutes left when Gordon made 3-pointers on consecutive possessions to put Houston up 92-89. Gordon had missed six of seven 3-point attempts before making those shots.
Phoenix made the next four points, with a 3 from Josh Jackson, to regain the lead before a 3 by Harden put Houston up 95-93 midway through the quarter.
The game was tied at 71 with about five minutes left in the third before Houston used a 5-2 run, capped by a 3 from Harden, to take a 76-73 lead. But Phoenix used a 5-2 spurt after that, highlighted by a soaring dunk from Richaun Holmes, to tie it back up a couple of minutes later.
A 7-2 run by the Suns later in the third put them on top 85-82. Kelly Oubre Jr. had a 3-pointer in that stretch and Holmes scored the other four points.
Kenneth Faried made one of two free throws after that cut the lead to 2 entering the fourth quarter.
Suns: Tyler Johnson sat out with a sore right knee. … Holmes looked to have injured an ankle in a collision with Harden with about 9 1/2 minutes left and didn’t return. … Oubre had 22 points. … Ayton had 17 points and 14 rebounds.
Rockets: The Rockets had 11 3-pointers to give them at least 10 in 42 straight games, which is the second-longest streak in NBA history behind their 55-game streak last season. … Harden had six steals and three blocked shots.
Suns: Visit New Orleans on Saturday.
Rockets: Host Minnesota on Sunday night.