Kyle Lowry scored a career playoff-high 36 points, including the go-ahead 3-pointer after Toronto had blown a 26-point lead, and the Raptors beat the Nets 115-113 on Wednesday night to take a 3-2 lead in their first-round series.
DeMar DeRozan had 23 points, Jonas Valanciunas scored 16 and Greivis Vasquez added 15 for the Raptors, who would advance to face Miami in the second round with a victory in Game 6 on Friday in Brooklyn.
Game 7, if necessary, would be Sunday in Toronto.
Joe Johnson scored 30 points and Mirza Teletovic had 17 for the Nets, who scored 44 points in the fourth quarter but lost their final chance when Andray Blatche fired a pass well over Deron Williams' head into the backcourt for a turnover.
Toronto led 94-72 on a 3-pointer by Vasquez with 11:23 remaining, but Brooklyn scored 15 of the next 18 points, including a four-point play by Alan Anderson, to make it 97-87 with 7:15 remaining.
Johnson later converted a three-point play, then made a 3 to tie it at 101 with 3:16 left.
Lowry put Toronto back on top with a pair of free throws, and a 3 by Vasquez gave the Raptors a five-point lead with 2:46 left.
Two free throws by Blatche and a 3 by Teletovic tied it at 106 with 1:23 left, but Lowry made a 3, then followed a layup by Blatche with a driving hook shot, putting the Raptors up 111-108 with 27 seconds remaining.
Johnson missed a jumper and DeRozan was fouled after grabbing the rebound, making both to put Toronto up by five, but Amir Johnson fouled out on Anderson's corner 3. Anderson's free throw made it 113-112 with less than 10 seconds left.
DeRozan added two more free throws to give Toronto a 115-112 lead with 6 seconds left. After a timeout, Blatche was fouled and made the first free throw but missed the second. Blatche grabbed the rebound and tried to pass it to Williams but the ball sailed into the backcourt for a turnover, sealing victory for Toronto.
Brooklyn led 23-18 on a 3 by Anderson with just over two minutes left in the first, but the Raptors reeled off seven straight points, including a 3 by Lowry, to take the lead. Lowry hit another 3 before the quarter ended and Amir Johnson scored nine points in the first as Toronto led 28-25 after one.
The Raptors used another huge surge to widen their lead in the second quarter. A three-point play by Marcus Thornton put the Nets up 40-36 with 5:26 left in the half, but Lowry scored five points in a 13-0 run to give Toronto a 49-40 lead, causing the Nets to call timeout.
Paul Pierce stopped the run with a driving basket, but the Raptors scored the final eight points of the half, including a buzzer-beating 3 by Lowry that went in off the glass. Toronto led 62-44 at halftime, setting a playoff record for points in a half.
Joe Johnson scored 18 points in the third for Brooklyn, but the Raptors pulled further away thanks to eight points from Valanciunas and seven by Lowry, taking a 91-69 edge into the fourth.