MIAMI (AP) -- Game on the line, LeBron James knew he was going to get to the rim.
And he delivered.
James scored 26 points, including a go-ahead layup after getting past DeQuan Jones with 3.2 seconds left, and the Heat scrambled late to beat the Orlando Magic 97-96 on Wednesday night and extend their franchise-record winning streak to 16 games.
''I had no intention of shooting another jumper,'' James said.
He missed a pair of 3-pointers about 90 seconds earlier, so he went for the 3-footer instead. From the right wing, James drove diagonally through the lane, then used his left hand - after all, he is left-handed - for the basket that won it for Miami. It was the first time he came up with what became a game-winning basket in the final five seconds of a game since a 3-pointer beat the Magic in the 2009 playoffs, according to STATS LLC.
''This is tough,'' Magic coach Jacque Vaughn said, after his team fell to 0-2 against Miami this season - the two losses by a total of three points. ''You've got guys who battled, who really wanted to win this game and deserved to win this game.''
Dwyane Wade scored 24 points on 10-for-16 shooting - he's now shooting 62 percent in his last seven games - and Chris Bosh added 17 points and 10 rebounds for the Heat, who blew a 20-point, second-half lead and then rallied from a five-point deficit in the final minutes.
Nik Vucevic had 25 points and 21 rebounds for the Magic, who got 16 points apiece from Jameer Nelson and Tobias Harris, 13 from Arron Afflalo and 12 from Maurice Harkless.
''They're one of the best teams in the NBA, if not the best and we gave it our all,'' Harris said. ''They knew that. It's just a matter of a couple of seconds that could have changed the game. It's a tough loss for us but it's the right step in the right direction.''
Vucevic now has two games of 20 rebounds or more in his career - both this season, and both against Miami. He had a 20-point, 29-rebound effort in a loss to the Heat on Dec. 31.
But he was one of three Magic players to foul out in the final minutes, as Orlando let a golden chance go awry.
The foul discrepancy in the game - 30 for the Magic, 17 by Miami - was a hot topic in the Orlando locker room afterward. The Magic went 10 for 12 from the foul line, Miami 27 of 31.
Perhaps the biggest two calls of the game came late, and both went Miami's way, although the Heat didn't like one of those at first.
Nelson hit a jumper with 1:36 left, giving the Magic a 96-93 lead. James missed two 3-pointers on the next Miami possession, and on the ensuing Miami trip, Harris drove from the left baseline but his basket was waved off, with Shane Battier beating him to the spot and drawing an offensive foul, Harris' sixth of the night.
Battier said he had no hesitation about the charge.
''He is defined by winning plays,'' Heat coach Erik Spoelstra said. ''He just continues to make them.''
Miami tried for the tie twice on the next trip, but Wade and Ray Allen missed 3-pointers. Bosh was fouled on a rebound - the sixth on Vucevic, making him the third Orlando player to reach the limit in the final minutes. Bosh made both free throws to get the Heat within one with 38 seconds remaining.
Al Harrington missed a wild 3-pointer, and James got the rebound to seal the stop Miami desperately needed. So with 12.6 seconds left, the Heat got the ball and a chance to win.
Spoelstra had told referees that if Miami got a stop, the Heat did not want a timeout. One was whistled anyway, and Spoelstra said that referees apologized for the miscommunication afterward. No matter - the play got set up, the ball went to James, and he delivered in the clutch.
Orlando had no timeouts, and only managed a 3-point try by Afflalo from near midcourt as time expired.
''It's about getting W's and trying to find a way not get L's,'' Wade said. ''Tonight we found the way.''
The Heat came in with 44 wins, the Magic with 44 losses, and after two possessions of the second half the reigning NBA champions had a 20-point lead.
And then about one quarter later, they were losing.
Vucevic had 10 points and nine rebounds in the third quarter alone - the Heat, as a team, had four rebounds in the period - and the tide of the game totally turned in a matter of minutes. What was a 60-40 Miami lead got whittled down steadily, with the Magic getting within 15 after a jumper by Afflalo, then 10 on a hook shot by Vucevic, five on a 3-pointer by Harris and finally within 77-74 when Vucevic closed the quarter with two free throws.
Orlando didn't stop there, either. Nelson made a contested 3-pointer to tie the game at 79-all with 10:29 left, and his three-point play about a minute later gave the Magic their first lead of the night.
Vucevic added back-to-back baskets, and suddenly, Orlando was up 86-81 with 8:29 left - meaning the Magic run, in about 14 minutes of actual playing time, was a 46-21 burst.
''Maybe it's the way they defend,'' Vucevic said. ''They give me open looks and a chance to rebound a little bit more.''
Miami answered with the next six points to briefly re-take the lead, but Vucevic struck again with 5:03 remaining, getting a short shot off the glass to drop and stake the Magic to a 91-87 edge.
In the end, James was one play better.
''He took it into his own hands,'' Spoelstra said.
NOTES: James was in double figures for his 200th straight regular-season game with the Heat, extending his franchise record. ... Vaughn played against Miami 30 times in his career, his teams going 15-15. ... The Heat have honored a military member who has returned home from a tour of duty in Iraq or Afghanistan before games in Miami for the past several seasons. Their honoree on Wednesday: Army 1st Sgt. Darrell Williams, who returned just two weeks ago from serving a tour in Afghanistan - and is the first cousin of Bosh's wife, Adrienne Bosh.