DeMar DeRozan scored 22 points, Gay had 17 and John Lucas scored 12 of his 14 points in the final quarter as the Raptors won their third straight.
It was the second game-winner in three games for Gay, who beat Indiana with an overtime jumper last Friday.
Kyle Lowry had 11 points and 10 assists and Alan Anderson had 10 for Toronto, which made seven 3-pointers in the fourth quarter.
Ty Lawson led Denver with 29 points, Kenneth Faried had 15 points and 11 rebounds and Anthony Randolph scored 16.
Andre Miller scored 12 points for the Nuggets, who came in having won nine of their past 10 overall and 15 of their past 17 meetings with Toronto.
Denver lost its second straight after having a nine-game winning streak snapped with a triple OT loss at Boston on Sunday.
The Nuggets had to juggle their starting lineup due to the absences of leading scorer Danilo Gallinari (sinus infection) and third-leading scorer Andre Iguodala (strained neck). Corey Brewer started in place of Gallinari, while rookie Evan Fournier took over for Iguodala.
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.
[to top of second column]
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.
Press; By IAN HARRISON]
Copyright 2013 The Associated
Press. All rights reserved. This material may not be published,
broadcast, rewritten or redistributed.