TORONTO -- Wayne Ellington's basket with time running out earned the Miami Heat a 90-89 road victory over Toronto on Tuesday night, snapping the Raptors' home win streak at 12 straight games.

Toronto (28-11) was chasing a club-record 13th straight win at the Air Canada Centre but fell to 14-2 on home court this season. The Raptors were minus point guard Kyle Lowry, who suffered a back injury Monday night in the club's 114-113 overtime road win over Brooklyn.

Delon Wright drew the start in Lowry's place, registering 13 points, seven rebounds and four assists.

DeMar DeRozan had 25 points for Toronto, and put the Raptors ahead 89-88 with 3.1 seconds remaining. But Ellington's driving layup stunned the crowd that included Buffalo Bills quarterback Tyrod Taylor.

Goran Dragic had 24 points to lead the Heat (23-17), which led by as much as 12 points and improved to 14-3 when holding opponents under 100 points. Bam Adebayo added 15 points while Toronto native Kelly Olynyk had four points and five rebounds.

Toronto made it interesting in the fourth, pulling to within 76-73 on Norm Powell's field goal with 8:31 remaining. But Miami responded with consecutive field goals to go ahead 80-73 with 6:21 to play.

The Raptors made it 80-77 with 5:11 remaining on Wright's two free throws, but Miami again countered with consecutive baskets for an 84-77 lead. Toronto proved resilient once again as Wright's three-pointer cut the Heat's lead to 86-83 with 3:20 to play.

DeRozan's layup with 2:23 remaining made it a one-point game before he put Toronto ahead 87-86 with under two minutes to play.

Dragic helped Miami go ahead 88-87 before DeRozan and Ellington exchanged baskets for the thrilling finish.

Things got testy at 7:50 of the third when Miami's James Johnson and Toronto's Serge Ibaka were ejected following an altercation with the Heat leading 55-52. Jonas Valanciunas's field goal had pulled Toronto to within 53-52 as part of an 11-2 run by the home team to open the quarter.

But six straight points by Dragic put Miami ahead 63-54 with 4:47 remaining. Consecutive C.J. Miles three-pointers cut Toronto's deficit to 70-64 but the heat still took a 72-64 advantage into the fourth.

Miami took a 51-41 halftime lead by outscoring Toronto 20-10 to snap a 31-31 tie in the second. Neither team shot well (36.4 per cent for the Raptors, 38.2 per cent for the Heat) but the visitors held a 13-4 edge in fast-break points and 13-5 in second-chance points.

Dragic had 14 points in the first half for Miami while Wayne Ellington added 13. DeRozan had a team-high eight points for Toronto but made just 3-of-13 shots as Wright, Valanciunas and Ibaka had six points.

Ellington and Hassan Whiteside both had six points to lead Miami to a 22-21 lead to end a sloppy first as the Heat shot just 32.1 per cent while Toronto was at 36 per cent. Valanciunas had six points for the Raptors as DeRozan made just one of his seven shots.