The Heat escaped some close calls against teams with losing records during its franchise-best winning streak.

On Wednesday night, LeBron James delivered a sweet finish to win No. 16 in a row.

James drove to the basket and delivered a left-handed layup in traffic with 3.2 seconds left to help the Heat pull out a 97-96 comeback win over the Magic at AmericanAirlines Arena.

It was Miami’s first one-point win of the season and 12th in a row at home.

The Heat’s victory extended its winning streak to 16, moving it into a tie with seven other teams for 18th on the all-time list of longest regular-season winning streaks.

The Heat also tied the 1964-65 Boston Celtics for longest winning streaks by a defending NBA champion.

The streak is the second-longest this season behind the Clippers, who won 17 in a row from Nov. 28 to Dec. 30.

It was the Heat’s fourth victory against a sub-.500 opponent by five points or less during the streak.

James had just missed a pair of three-pointers a minute earlier that could have tied the score.

James said he was determined not to miss a third time.

“I was just trying to be patient and see if I could penetrate to the hole and I was able to do that and finish,” James said. “I had just settled for two threes before that so there was no way I was going to shoot another jumper on that play.”