MIAMI (AP) -- The subplots were obvious: Goran Dragic vs. Luka Doncic for the first time, Dwyane Wade vs. Dirk Nowitzki for the last time.
Miami got the better of both.
With an estimated 2,000 Slovenian fans in the stands - most if not all of them staying and chanting for him long after the game - Dragic had 23 points, 12 rebounds and 11 assists for his second career triple-double, Wade capped the win with a steal and score in the final seconds and the Heat moved back into eighth place in the Eastern Conference by topping the Dallas Mavericks 105-99 on Thursday night.
''It felt like we were in Ljubljana,'' Heat coach Erik Spoelstra said, speaking of the Slovenian capital.
Whatever it was, wherever it felt like, the Heat (37-38) got a much-needed win. They improved to just 4-29 in games where they trailed after three quarters and moved past Orlando (37-39) for the final playoff spot in the East standings - with Dragic outdueling Doncic in the first head-to-head meeting between the only two Slovenians currently in the NBA.
''He's the old Don and Luka is the new up-and-coming,'' Wade said about Dragic. ''So it was great to see him play that way.''
Doncic scored 19 points for the Mavericks, but missed 12 of his 18 shots. Nowitzki scored 13 points for Dallas, as did Jalen Brunson. When it was over, Doncic and Dragic - teammates on the Slovenian team that won the European championship two summers ago - exchanged hugs and jerseys. Miami swept the season series from the Mavs, but Dragic didn't play in the Heat win at Dallas.
''It was great. Honestly maybe for the first time in my career I was nervous before the game,'' Doncic said. ''It was different for me, but it was a special night.''
Dion Waiters scored 17 points for the Heat, who improved to just 4-29 in games where they trailed entering the fourth quarter. Dallas led 82-75 going into the final period, but the Heat outscored the Mavericks 30-17 in the last 12 minutes.
Dallas led by 11 points in the first half, and took a 59-49 lead into the locker room after a tip dunk by Dorian Finney-Smith beat the halftime buzzer. But Wade hit a jumper with 1:11 left to put Miami on top for good, Doncic missed a long 3-pointer on the next Dallas trip down the floor and Dragic extended Miami's lead to 100-97 with a nifty up-and-under move on the ensuing Heat possession.
And with that, the building roared. The Miami fans might have even been drowned out. Countless Slovenia jerseys were spotted in the stands, along with scarves bearing the country's name, all for very good reason.
They were there for Dragic vs. Doncic.
They got a show, too.
''To buy a ticket, to fly from a different continent here and to stay here and support us, it's something amazing,'' Dragic said, before he went back out, addressed the crowd 30 minutes after the game and signed autographs.
Dragic's only other triple-double came in 2011 - 11 points, 11 rebounds and 11 assists for Houston over Minnesota in a season-finale. That was basically meaningless. This one meant plenty to the Heat, fighting to get into the playoffs in Wade's final season, and a loss to the team that they faced in the 2006 and 2011 NBA Finals certainly would have hurt those postseason chances.
Nowitzki had a chance to tie with a 3-pointer - shooting it over a closeout by Wade - with 59 seconds left. Nowitzki's shot sailed long, and the Heat could finally exhale when Wade got a steal and laid it in to cap the scoring with seven seconds left.
''He looks like he's got a couple years left,'' Nowitzki said about Wade. ''He can still take games over, he's making good decisions with the ball, he's still athletic enough to get by people. So to me, he looks great.''
It was the 35th and final time Wade and Nowitzki went head-to-head, including playoffs. Wade won the series, 18-17.
''This was the most I've ever guarded Dirk,'' Wade said. ''It was cool.''
Mavericks: Dallas dealt with a couple injury scares early - Nowitzki rolled his ankle pregame but started the game, and Doncic left after 3 minutes following a knee-to-knee collision with Miami's Derrick Jones Jr. Doncic returned later in the first quarter. ... Mavs assistant Jenny Boucek was an assistant for the WNBA's Miami Sol, under original Heat coach Ron Rothstein.
Heat: Josh Richardson (bruised left heel) was out, joining Justise Winslow (sore right thigh) and Rodney McGruder (sore left knee) as Heat regulars out with injuries.... Friday is the 16th anniversary of Wade's triple-double - 29 points, 11 rebounds, 11 assists - in the NCAA tournament for Marquette against Kentucky, the game that sent him to the Final Four.
DIRK IN MIAMI
This was the 27th time Nowitzki appeared in a game at Miami; the Mavs went 13-14 in those games, the most notable win being the title-clinching Game 6 of the 2011 NBA Finals. He says being in Miami brings back memories of both ''the most epic collapse'' in the 2006 finals, and the 2011 victory. ''Little bit of mixed emotions, but usually, the good memories win,'' Nowitzki said.
The Heat used their 25th starting lineup. That ties last season's club for the third-most in franchise history behind 31 in 2014-15 and 30 in 2007-08. Entering Thursday only New Orleans (29), Cleveland (28) and Phoenix (26) have used more starting fives. The NBA average is just under 18, and Orlando - with only eight lineups so far - has used the fewest.
Mavericks: At Oklahoma City on Sunday.
Heat: At New York on Saturday.