Denver was also depleted by the loss of forward Wilson Chandler, sidelined by a sore groin. Things got worse for the Nuggets when center JaVale McGee left at halftime with a sore left leg.

Lucas' third 3-pointer of the fourth quarter put Toronto up 91-83 with 9:10 remaining, but Denver scored six straight points to make it 91-89.

Anderson hit Toronto's sixth 3-pointer of the fourth, putting the Raptors up 100-94 with 5:13 to play, but Lawson scored six of the next eight points, all on layups, before a reverse layup by Brewer tied it at 102-all with 3:02 left.

After Denver took a 108-107 lead on a pair of free throws by Randolph with 42 seconds left, the Raptors recovered the ball following a missed shot, then called timeout to draw up a play for Gay, who hit the go-ahead basket over Brewer from just outside the paint.

A driving Lawson got off a final chance for the Nuggets, but his shot rimmed out at the buzzer.

The Raptors led 22-9 after Gay's 3-pointer with 4:07 left in the first but the Nuggets fought back to make it 28-21 after one quarter. Gay scored 13 points in the first and DeRozan had eight for Toronto.

DeRozan opened the second quarter with a soaring dunk over Denver's Timofey Mozgov, and Toronto rookie Terrence Ross, who'll compete in the dunk contest at All-Star weekend, later added a breakaway dunk to put the Raptors up 43-31 with 6:28 left in the half. But the Nuggets got 14 points from Lawson in the second, slicing the deficit to 54-52 at the half.

Denver took its first lead since the game's opening basket on a dunk by Faried with 7:02 left in the third, but Toronto closed the quarter with back-to-back baskets by Lucas and DeRozan to take an 82-78 lead into the fourth.

NOTES: Andrea Bargnani returned after sitting out Sunday's win over New Orleans with flulike symptoms. ... Kosta Koufos had 10 rebounds for the Nuggets. ... Both teams were off to New York for their final game before the All-Star break. Toronto visits the Knicks on Wednesday while Denver is in Brooklyn to face the Nets.