Harden scored 27 points and the Rockets rallied from a 20-point deficit for a 106-100 victory over the Cavaliers, who rested James.
Cleveland led 62-42 early in the third quarter before Houston, fighting to make the playoffs, roared back. Harden scored 18 points in the fourth and Houston outscored Cleveland 35-16 in the period.
"That's what the first three quarters were for -- to figure out what they were doing," Harden said. "Even when we got down 20 points, we felt confident because they weren't shooting the ball well, even when they were winning."
Cleveland led 91-83 on Thompson's basket with 6:36 to go, but the Rockets used a 12-0 run to go ahead. The Cavaliers didn't score again until Irving hit a free throw with 2:44 left. Irving's jumper with 2:17 to go tied the game at 94 but Houston then went ahead for good.
"They got stops and we couldn't make a shot," Cleveland coach Tyronn Lue said. "They were able to get out in transition and that kind of got James Harden going. That got him feeling good about himself."
Lue announced Monday that James would sit out the game as the Cavaliers try to rest their key players as much as possible over the final games of the regular season.
James, dressed in a suit, jumped up from the bench several times to encourage his teammates and joined Lue near midcourt to bark out instructions late in the second quarter.
Cleveland made six 3-pointers in the second and built a 59-40 halftime lead, but finished 14 of 40 from behind the arc.
Rockets guard Patrick Beverly, who hit a critical 3-pointer in the fourth quarter, has a simple theory when it comes to Houston being successful.
"The thing about us is to not get in our own way," he said. "When we do that, we're fine."
Lue praised Thompson for his durability during his consecutive-games played streak.
"There are a lot of times when guys are sick or you could be hurt and he still plays through the pain," Lue said. "For a guy who plays hard like he does and takes the pounding he does, it means a lot. It's a tribute to him."
Rockets: Houston scored 14 points and made 5 of 18 shots in the second quarter. ... The Rockets snapped a four-game losing streak on the road.
Cavaliers: James is four points away from passing Dominique Wilkins for 12th place on the NBA's all-time scoring list. The four-time MVP has 26,665 career points.