MIAMI -- It took a record-setting night from 3-point range for the Miami Heat to beat the Orlando Magic.

Duncan Robinson scored 27 points, all of them coming from beyond the arc, and the Heat hit a franchise-record 22 3-pointers in their 116-113 win over the Magic on Wednesday night.

Goran Dragic scored 25 points and added nine assists, Kelly Olynyk scored 16 on a perfect shooting night and Jimmy Butler finished with 12 points, eight assists and seven rebounds as Miami won its fourth straight.

The previous record for Heat 3-pointers was 21, set April 5, 2017, at Charlotte. The 22 3-pointers made also tied the most allowed in a game by Orlando.

"My teammates encouraged me to shoot. The coaching staff encourages me to shoot," Robinson said. "So I just went out and tried to be aggressive."

Terrence Ross had season-highs of 35 points and eight 3-pointers for the Magic, who have dropped three straight yet remain in the No. 8 spot in the Eastern Conference playoff race.

The game became just the second in NBA regular-season history where two players made at least eight 3-pointers. The other: Jan. 5, 2019, when Stephen Curry made 10 for Golden State and Buddy Hield made eight for Sacramento. It has also happened once in a playoff game, when Draymond Green and Damian Lillard both made eight in a Golden State-Portland matchup on May 7, 2016.

Nikola Vucevic scored 22 points and grabbed 16 rebounds for the Magic, while Evan Fournier finished with 17.

"The biggest factor in that game was totally on me," Magic coach Steve Clifford said. "We just didn't have a good Option B for Duncan Robinson until halftime. We made adjustments at halftime. Our guys did a good job, but that was the difference in the game."

Even after the 3-point barrage by Miami, Orlando still had a chance at the end.

Down three with 6.2 seconds left after the Heat took the last foul they had left to give, the Magic went to Aaron Gordon -- who got a good look at a 3-pointer from the right corner. It hit the rim, the Heat controlled the rebound and time expired.

Robinson missed his first shot, a 3-pointer from the left corner. His next seven were all 3s, and all connected. He was 7 for 8 from distance in the opening 24 minutes, becoming the first player in the NBA to have two first halves with at least seven 3s this season -- he had eight in the first half against Cleveland on Nov. 20.

"Some of those 3s they made were hard shots and sometimes that happens," Vucevic said. "I thought defensively we were better. There are some mistakes that we didn't take care of."

The Heat needed all Robinson had, because the Magic weren't going away.

Orlando was down by as many as 15 midway through the second quarter, then used a 13-2 run over a stretch of 2:55 late in the half to get right back into things. Miami's lead was down to 60-55 at the break and the Heat led 88-84 after a back-and-forth third quarter that featured 10 lead changes.

TIP-INS

Magic: Wednesday was the start of a four-game road swing for Orlando, the longest trip left on its schedule. The Magic play 10 of their final 17 games at home. ... James Ennis III started one game out of the 30 he played in Miami as a member of the Heat. He has now started two of the four he's played in Miami as an opponent.

Heat: Robinson's streak of games with at least one 3-pointer is now at 47, two shy of matching Rafer Alston's Heat record. He has made multiple 3s in 45 of those 47 games. ... Olynyk was 5 for 5 from the field, 3 for 3 from 3-point range and over his last five games is shooting 19 for 25 from the field, including a staggering 13 for 15 from 3-point range. He's averaging 11.6 points in just under 16 minutes per game in that stretch.

SAD MEMORY

Wednesday marked exactly 30 years since Loyola Marymount's Hank Gathers collapsed and died on the court in a game against Portland -- a moment where Heat coach Erik Spoelstra, then a guard for Portland, was on the court and just a few feet away from the high-scoring star. Spoelstra has spoken of that day, that moment, many times. "That's going to be etched in my memory until the end," Spoelstra said.

STATE TITLE

Miami won the season series 3-1, the first time in the last four years and the 15th time in 31 years overall that the Heat could claim in-state bragging rights. Orlando has won the season series nine times, and the clubs have split the other seven. "This is our state," Heat center Meyers Leonard tweeted postgame.

UP NEXT

Magic: Visit Minnesota on Friday.

Heat: Visit New Orleans on Friday.

---

More AP NBA: https://apnews.com/NBA and https://twitter.com/AP-Sports