Held in check after a great first quarter, Rudy Gay said he wasn't proud of his performance.

None of his Toronto Raptors teammates saw anything to complain about.

Gay hit a pull-up jump shot with less than five seconds remaining and the Raptors beat the short-handed Denver Nuggets 109-108 on Tuesday.

It was the second game-winner in three games for Gay, who beat Indiana with an overtime jumper last Friday.

"He's a big time player," Raptors coach Dwane Casey said. "He's a closer."

Only four of Gay's 17 points came after the first, and he spent long stretches of the second half stuck on the bench after landing in foul trouble.

"It just feels good to get a win," said Gay, acquired from Memphis on Jan. 30 in a three-team trade. "Obviously it's a not a game I'm proud of, but I'm proud to get this win."

Denver coach George Karl said before the game that Gay has given the Raptors "a different personality."

"They seem to have more energy," Karl said.

Nuggets point guard Ty Lawson said there's an obvious change in Toronto's confidence since adding Gay to the lineup.

"Rudy brings that because Rudy is a confident person," Lawson said. "He makes big shots."

DeMar DeRozan had 22 points and John Lucas scored 12 of his 14 points in the final quarter as the Raptors won their third straight.

Kyle Lowry had 11 points and 10 assists and Alan Anderson had 10 for Toronto, which made seven 3-pointers in the fourth quarter.

Lawson led Denver with 29 points, Kenneth Faried had 15 points and 11 rebounds and Anthony Randolph scored 16.

"It seems like the ball wasn't bouncing our way," Karl said. "A lot of things were going against us."

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.

"That's tough," Lawson said. "We didn't know till today so we couldn't really plan for it."

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.

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.

"This one is even harder for me than Boston," Karl said.

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.

"I was supposed to get the handoff and then it was basically a one-on-one," Lawson said. "I fumbled it a little bit. Kyle Lowry got his hand on it. I had to rush the shot with two seconds left. I think I got the best shot I could get."

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.

Gay called DeRozan's eye-popping slam "one of the craziest dunks I've ever seen."

"The sky's the limit for him, he's an incredible talent," Gay said.

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: This was Toronto's first victory over the Nuggets since a 105-96 home win March 28, 2012. ... Andrea Bargnani returned after sitting out Sunday's win over New Orleans with flulike symptoms. ... Kosta Koufos had 10 rebounds for the Nuggets. ... Toronto allowed a season-high 70 points in the paint. ... Denver has scored 100 points or more in 12 straight games. ... 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.