MIAMI -- The last offensive play for the Miami Heat did not go as planned. In the eyes of Heat coach Erik Spoelstra, the two-time defending NBA champions pretty much botched the whole thing.
Except the ending, that is.
"It helps to have LeBron James," Spoelstra said.
James bailed out the play -- and delivered the eventual game-winner in the process. His jumper with 15.1 seconds left provided the final points, and the Heat rallied from 16 down in the second half to beat the Orlando Magic 101-99 on Saturday night.
Dwyane Wade scored 27 points in his return to the lineup after missing two games to rest his knees, James added 22 and Chris Bosh had 15 for the Heat (10-3), who have won six straight. This marked the first time the Heat needed to rally in the final quarter.
"I cleared out and he did the rest," Wade said of Miami's final offensive play. "He made an unbelievable shot."
Glen Davis, playing for the first time since Jan. 30 because of a broken left foot, scored 20 points for the Magic, who fell to 0-5 on the road. Arron Afflalo and Victor Oladipo had shots in the final 5 seconds, but neither fell -- Oladipo's skipped off both sides of the rim -- and Miami escaped when James got the game's last rebound as time expired.
He threw the ball downcourt, tossed his headband and wristbands into the stands, and exhaled deeply.
"LeBron in space, and he'll take care of the rest," Spoelstra said of Miami's last play. "But the execution before that was extremely poor, very poor. And he just did what great players do. He was very relaxed, calm, got to a spot where he felt comfortable and shot a great in-rhythm jump shot that made all of us look better."
Afflalo scored 18, Oladipo added 17 and E'Twaun Moore had all of his 14 points in the first half for Orlando, which let one slip away. In the first 43 minutes, the Heat led for all of 54 seconds, and were getting blown out for a while.
In the end, they had the only lead that mattered.
"We know that they are a team that can get things going pretty quickly," Magic coach Jacque Vaughn said.
Bosh's jumper with 4:30 remaining put Miami up 89-88, and from there it got frantic to the end. James made a 3-pointer over Davis for another Heat lead with 3:47 left, then took a charge against the burly power forward 19 seconds later, grimacing as he got off the hardwood.
Miami led by four points on a pair of occasions, and the lead was three with just under a minute to play. Afflalo missed a 3-pointer that would have tied it, but Davis got the rebound, went into the lane, drew contact from Bosh and got a shot to fall. The free throw rattled and dropped with 37 seconds left, and the teams were tied at 99-all.
Orlando didn't score again.
"I wouldn't want to come back against no other team," said Davis, who got three stitches near his right eye after the game. "This was a great team to come back and play. I'm just happy to be back no matter if we're playing the NBA champs or we're playing (the New Orleans) Pelicans or something, I'm just happy to play basketball and show the world that I can contribute to a team. I'm just happy I'm back."
James added nine rebounds and seven assists for the Heat, plus reached double figures for the 508th straight regular-season game, tying Kareem Abdul-Jabbar for the fifth-longest streak in NBA history.
Moore had all his points in the second quarter, on 5 for 5 shooting, 4 for 4 from 3-point range. When Afflalo got a 3-pointer to rattle off the rim a couple times and finally fall with 7 seconds left in the half, the Magic owned a 55-39 lead to take into the intermission.
By the time Orlando got its first points of the second half, that lead was largely gone.
Miami opened with 10 straight points in the third quarter, with James hitting a pair of 3-pointers and Wade capping it all by going down the middle of the lane for a dunk.
Just like that, 55-39 became 55-49, and the Heat had life. And in the end, they had a win as well, albeit a much tougher one than the 28-point romp at Orlando on Wednesday.
"That's the nature of the game," Wade said. "We knew they were going to play better tonight."
After playing twice in four days, the teams do not meet again until Miami visits Orlando on Jan. 4. ... James had a stuff-like-only-he-does sequence in the third quarter when he got a deflection and steal, gathered the loose ball, dribbled upcourt and threaded a one-handed crosscourt pass between plenty of Orlando defenders to set Ray Allen up for a 3-pointer.