"We feel we're a good team but we have some work to do," Heat coach Erik Spoelstra said.

Miami fell a half-game behind idle Philadelphia for seventh in the East. The Heat visit the 76ers on Wednesday.

"We definitely understand where we are in the standings," Dwyane Wade said. "Coach makes sure we see the standings every day."

Wade had 10 points and 11 rebounds for the Heat, and Hassan Whiteside collected 10 points and 10 boards.

Toronto led 112-96 with 4:42 left but back-to-back baskets by Dragic capped a 13-0 spurt that made it 112-109 with 56 seconds left.

"Closing out games has been an issue for us," Raptors coach Dwane Casey said. "We had a comfortable 15-point lead and then we got comfortable."

DeRozan stopped the run when he was fouled and missed the first free throw before making the second.

After a Miami timeout, Dragic missed a 3 and Toronto's Pascal Siakam grabbed the rebound. Lowry was fouled and made one, putting Toronto up five with 27 seconds left, but a 3 by Wayne Ellington made it 114-112 with six seconds remaining.

Miles split a pair of free throws before Josh Richardson's last-chance 3 went wide.

Dragic scored 16 points in the third but the game turned after he went to the bench. DeRozan scored 19 points in the quarter, nine of them in a 21-4 run over the final 4:34 as the Raptors took a 98-81 lead into the fourth.

"They just seemed to score every time down going the other way and we weren't able to hold the fort," Spoelstra said.

TIP-INS

Heat: F Kelly Olynyk (left shoulder) missed his third straight game. ... Miami made 16 turnovers, leading to 28 points for Toronto. .. The Heat have lost a season-worst four straight on the road.

Raptors: F OG Anunoby started after leaving Sunday's win at Charlotte because of a sprained right ankle. ... Fred VanVleet had 10 points, extending his career-long streak of double-digit games to eight.

AERIAL ACROBATICS

DeRozan had the dunk of the game, a one-handed finish on an alley-lop pass from Lowry.

NOTHING'S FREE

Three of Toronto's five missed free throws came in the final 41 seconds. Toronto shot 18 for 23 at the foul line.

RARE FEAT FOR HEAT

Miami is one of four teams to win in Toronto this season, beating the Raptors 90-89 on Jan. 9 when Ellington scored a last-second layup. Golden State, Utah and Washington also won at Air Canada Centre.

UP NEXT

Heat: Visit the 76ers on Wednesday. Miami lost at Philadelphia on Feb. 2.

Raptors: Visit Chicago on Wednesday. Toronto has won its past four meetings with the Bulls.