MIAMI (AP) — Dwyane Wade scored a season-high 27 points, the last of those coming on a jumper that gave Miami its only lead of the fourth quarter with 5.9 seconds left, and the Heat rallied to beat the Philadelphia 76ers 102-101 on Tuesday night.

Wade had 15 of his points in the fourth quarter, and the Heat won a game where they never led by more than three.

Goran Dragic scored 21 for the Heat, who got 16 points from Tyler Johnson and 15 points and 11 rebounds from Hassan Whiteside.

Joel Embiid scored 23 points for Philadelphia, which got 21 from Dario Saric. The 76ers led by as many as 10 in the fourth and had a chance to win at the buzzer, but JJ Redick’s wide-open 3-point try bounced off the rim.

Redick finished with 15 for the 76ers.

Wade was absolutely vintage down the stretch, and Miami needed him to be just that.

Redick got fouled shooting a 3 with 1:47 left, made all three free throws and put Philadelphia up 98-95. With 27 seconds left, Wade got fouled on a busted Miami play while trying a 3 from the left corner — making all three to tie the game at 100.

Then Miami rolled the dice — twice.

The first came when Wade intentionally fouled Simmons almost immediately after the ensuing inbounds pass. Simmons missed the first and made the second, and the Heat were down one with 23.8 seconds left.

The second was not calling timeout to set up the next play. Wade kept the ball for the entirety of the next possession, connecting on a 21-footer that ultimately was the deciding shot.

Philadelphia used a 16-3 run to open a 33-20 lead in the first half, and Miami answered with an 18-2 run to go up 38-35. From there, a 12-minute stretch of back-and-forth commenced with neither team ever leading by more than three.

The 76ers eventually broke through, going up nine late in the third. But they saw the margin cut to 75-73 going into the fourth, after Wade hit a step-back 3 to end the quarter. In the fourth, Philadelphia went up again, this time by 10 — and Miami clawed back again, using an 11-1 run to knot the game on a layup by Wade with 4:57 left.

And in the end, Wade won came through in a bigger way.

TIP-INS

76ers: It was only the second time that the 76ers and Heat met three times in the same regular-season month. Miami went 3-0 against Philadelphia in February 1996; 22 years later, the 76ers went 2-1 against the Heat. … Before it happened again in the fourth, Philadelphia got fouled twice on 3-point tries in the second quarter and made the utmost of the chances, converting them into seven points. Marco Belinelli made three free throws, and Redick turned his into a four-point play.

Heat: Coach Erik Spoelstra got a technical in the first quarter when Embiid wasn’t called for goaltending on a short shot by Wade. Replays indicated his argument was valid. … It was the 24th time in Miami’s last 26 games that the winning margin was less than 10 points. … Wade’s previous season high was 25, when he was with Cleveland.

MOTT LEAVES

Most of the second half was played with only two referees on the floor. Rodney Mott left the game early in the third quarter, accompanied by Heat athletic trainer Jay Sabol. Bill Spooner and Lauren Holtkamp finished the game.

MCGRUDER BACK

Heat guard Rodney McGruder, recovered from a stress fracture in his left leg, made his season debut in the third quarter. McGruder played in two G League games with Miami’s affiliate in Sioux Falls, the last being Monday in Ontario, California. McGruder flew out postgame on a redeye and landed in Miami around 1 p.m. Tuesday. The plan wasn’t to have him play Tuesday, but McGruder was needed after guards Wayne Ellington and Tyler Johnson got hurt.

UP NEXT

76ers: Visit Cleveland on Thursday, the end of a three-game trip.

Heat: Host the L.A. Lakers on Thursday, the third game in a five-game homestand.

(Copyright 2018 by The Associated Press. All Rights Reserved.)