The Heat (53-14) extended their winning streak to 24 games in a row. Miami haven't lost since February 1, a span of 47 days.
James recorded his fourth triple-double of the season with 25 points, 12 rebounds and 10 assists, all game highs.
The Cavs blew a 27-point lead, the largest in franchise history in a losing effort.
"Down 27, none of us were happy about it," Heat coach Erik Spoelstra said. "We caught lightning in a bottle.
"We had to take big home-run plays to get us back in the game. That's part of our greatness."
There was a lot of disappointment among the Cavs. They had the Heat on the ropes, but couldn't put them away.
"I'm sure everyone in (our) locker room wanted to get it done," Cavs coach Byron Scott said. "You have to give the Heat credit. That's why they're the defending NBA champion."
The Cavs (22-46) were playing without Kyrie Irving (sprained left shoulder), Dion Waiters (sore left knee) and Anderson Varejao (knee surgery). However, they led 67-40 with 7 minutes, 44 seconds left in the third quarter.
The Heat trailed by nine points after three quarters, 77-68.
However, James scored 11 of their first 12 points to take control of the contest. They blitzed the Cavs in the fourth, 30-18.
There were two delays in the action. The start of the game was delayed by 35 minutes with moisture on the floor.
"It was weird to have to go back into the locker room," Cavs coach Byron Scott said. "We had to come out and warm up again."
Then, with 8:21 left, a fan came out on the court to greet James wearing a T-shirt that read: "We miss you. Come back 2014."
"He looked like he had a few too many beers," Scott said.
James said he didn't see the guy until it was too late.
"I didn't see him until he was in my face," he said. "I had no reaction."
He said the comeback was fuelled by the Heat's defence. They outscored the Cavs in the second half, 64-40.
"We had to get stops," James said. "That's what got us back into the game, getting stops. Shane Battier's two 3s helped our defence. Tonight our offence helped our defence."
James said he wasn't concerned with the second-longest winning streak in NBA history.
"The streak wasn't on my mind," he said. "Getting blown out was on my mind.
"It was a good quality win, especially being down like we were. We were down by 27 with 18 minutes left in the game, but that's a lifetime."
Cavs swingman C.J. Miles missed a 3-pointer at the buzzer that would have tied the game.
James dropped in two free throws with 4.7 seconds left, which extended the Heat's lead to three points.
The Cavs have lost to the Heat three times this season by a combined nine points.
Miami trailed by 21 points at halftime, 55-34. It proved to be the largest halftime deficit from which the Heat has ever come back.
Guard Mario Chalmers contributed 17 points for the Heat, while Chris Bosh, Dwyane Wade and Battier all added 11.
Guard Wayne Ellington had a team-high 20 points for the Cavs, while Thompson finished with 18 points, eight rebounds and three steals. Center Tyler Zeller had a double-double with 12 points, 11 rebounds and a block.
- - -
Rockets 100, Jazz 93
For the first time during their crucial seven-game homestand, the Houston Rockets opened a contest with energy, and they rode an early burst to a 100-93 win over the Utah Jazz.
The victory enabled the Rockets (37-31) to extend their lead over the Jazz (34-34) to three games in the race for the final playoff spot in the Western Conference.
- - -
Knicks 106, Magic 94
J.R. Smith had 22 points and Carmelo Anthony returned from his knee injury with 21 for the New York Knicks in a 106-94 win over the Orlando Magic at Madison Square Garden.
Anthony, whose right knee injury led to a prolonged absence, helped the Knicks make up for some other ailments with a revamped lineup for their second straight win.
The Knicks (40-26), who had dropped the first four games of a five-game road trip before salvaging the finale, backed up that victory with a win over the hapless Magic (18-51).
- - -
Hawks 98, Bucks 90
Al Horford had 26 points and 15 rebounds, and Jeff Teague added 27 points and 11 assists to lead the Atlanta Hawks to a 98-90 win over the Milwaukee Bucks.
Atlanta's Josh Smith finished with 12 points and a season-high 16 rebounds, including nine boards in the first quarter.
Teague had only two points in the first quarter but turned it on in the second, scoring five points in the last 27 seconds of the first half on a 27-foot 3-point jump shot and then a floater with three-10ths of a second left, putting the Hawks up 48-43 at halftime.
- - -
Bobcats 107, Raptors 101
Byron Mullens came off the bench to score 25 points and Gerald Henderson scored 21 as the Charlotte Bobcats pulled out a 107-101 victory over the Toronto Raptors.
The Bobcats led by as many as nine points in the fourth quarter and eventually held off a late Toronto surge, with Mullens hitting four free throws in the final 11.1 seconds to seal the victory.
The victory, coupled with a win over Washington on Monday night, gave the Bobcats a two-game winning streak for the first time since late November. They have had just three two-game winning streaks all season. They are now 16-52, still the worst record in the NBA.
- - -
Nets 113, Mavericks 96
Deron Williams spurned his hometown team last summer as a free agent and burned them Wednesday night with a huge second half to lead the Brooklyn Nets over the Dallas Mavericks, 113-96.
Williams poured in 31 points, 26 in the second half and 13 in the fourth quarter as Brooklyn (40-28) climbed out of a 10-point deficit to defeat Dallas (32-36).
- Sports & Recreation