Toronto (40-16) improved its NBA-best home record to 24-4 and ensured it will be the top team in the Eastern Conference at the All-Star break. The Raptors lead Boston (40-18) by 1 1/2 games. Both teams play their final game before the break on Wednesday night.
Serge Ibaka had 14 points and 10 rebounds for the Raptors, who also won six straight between Nov. 25 and Dec. 10 and again between Dec. 13 and 23.
C.J. Miles added 11 points, but the Raptors failed to extend its franchise-record five-game streak of winning by 15 or more points.
Goran Dragic scored 28 points and James Johnson had 16 for the Heat, who lost for the sixth time in seven games. Dwyane Wade had 10 points and 11 rebounds and Hassan Whiteside collected 10 points and 10 boards.
Toronto led by double digits for much of the fourth before back-to-back baskets by Dragic made it 112-109 with 56 seconds left. DeRozan was fouled and missed the first 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.
Lowry made a pair of 3-pointers in the final 30 seconds of the first half, including an unlikely buzzer beater, to give Toronto a 57-55 edge at the break. They were Lowry's only two made baskets of the second quarter.
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.
Heat: F Kelly Olynyk (left shoulder) missed his third straight game. ... James Johnson shot 5 for 5 in the first half.
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.
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.
More NBA basketball: https://apnews.com/tag/NBAbasketball
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.