CHARLOTTE, N.C. (AP) -- Kelly Olynyk scored 14 of his 16 points in the fourth quarter, including a free throw with 0.2 seconds left, to help the Miami Heat erase a five-point deficit in the final 34 seconds and stun the Charlotte Hornets 106-105 on Saturday night.

Wayne Ellington had 26 points on six 3-pointers, Joe Johnson had 22 points and Olynyk was brilliant down the stretch.

Nic Batum scored a season-high 26 points and Kemba Walker had 22 for Charlotte, which had a two-game winning streak snapped.

Charlotte led 105-100 when Johnson got free for a dunk. The Hornets inbounded the ball to Batum, but Josh Richardson ripped it from his hands and passed to Johnson, who knocked down a 3-pointer from the wing to tie.

After a timeout, Walker missed a driving layup, and Olynyk grabbed the rebound and drove the length of the court. He was fouled by Dwight Howard on a disputed reach-in call and made the second of two free throws.

The Heat deflected the ensuing inbound pass as time expired.

The Hornets trailed by eight in the third quarter before Batum got hot. The French shooting guard scored 14 points during a 16-6 run to give the Hornets their first lead since 2-0.

Charlotte stretched the lead to 10 to open the fourth quarter, but the Heat battled back behind three 3-pointers from Olynyk to cut the lead to three.

TIP INS

Heat: Goran Dragic sat out with a bruised knee. … The Heat shot 51 percent from the field in the first half to build a 57-48 lead.

Hornets: Howard had 14 points and 15 rebounds for the Hornets.

UP NEXT

Heat: Wrap up a five-game road trip on Monday night at Houston.

Hornets: Host Sacramento on Monday night.