MEMPHIS, Tenn. (AP) -- Dante Cunningham redeemed the Grizzlies after they blew a 23-point lead in the second half.
"The importance of that play - I don't have the words for it right now," guard Mike Conley said, "because I don't think that Cunningham understands how big of a play that was for this team and where our path is going from here."
Memphis had to hold its breath for one more stop, but Andre Miller's inbounds pass after a timeout was batted away at the rim, and allowed Memphis to win its third straight, despite blowing the lead.
Gay, who had 20 points to lead six Memphis players in double figures, took the 17-foot shot from the right baseline with about a second left. It was a shot he has hit to win games for Memphis in the past.
"It was front rim and it was straight, but it hit front rim," Gay said. "I thought it was going to go over it. I think it was a good shot. I kind of got to where I wanted to."
But Cunningham, who had only one other basket in the game, was able to get to the rim on the miss and tip in the winner. It was the only offensive rebound for Memphis in the final period.
"You have to go for it," Cunningham said of the situation. "You get an offensive foul going for a rebound at the end of the game with less than 5 seconds left, it really doesn't matter. You're going to lose anyway. You might as well give it your all and go for it."
O.J. Mayo finished with 17, Mike Conley and Marc Gasol scored 16 points apiece, Gasol grabbing 14 rebounds and handing out eight assists.
Tony Allen had 13 points and Marreesse Speights added 12 points and 10 rebounds.
Corey Brewer keyed the Nuggets rally, scoring a season-high 26 points, all in the second half, on 10 of 14 shooting.
Kenneth Faried and Ty Lawson finished with 18 points each. Faried also had 10 rebounds, tying a career high. His 18 points set a career high.
Miller scored 13 for the Nuggets and had nine assists.
"It was fun," Nuggets coach George Karl said. "We made the game real fun. Some guys made some good shots. Kenneth was great. Brewer was really good."
The Nuggets used Brewer's offense with Faried's help, to erase the Memphis lead by the 4:34 mark of the fourth.
Brewer's tip-in at that point gave Denver its first lead of the game at 91-90. There were seven lead changes and two ties in the final minutes.
Brewer's rebound dunk with 24.6 left gave the Nuggets a 102-101 lead, setting the stage for Cunningham's winning tip.
"We never quit. We're not a team of quitters," Faried said. "Everybody stayed focused, and everybody stayed hungry. We wanted to win this game.
"At the end, we just couldn't get that last rebound."
Memphis made 13 of its first 17 shots in a fluid execution of its offense. That helped the Grizzlies to a 21-point first-half lead, and they had a 60-43 advantage at the break.
"In the first half, I just feel like we were getting punked on the offensive boards and just overall as a team," Lawson said.
Memphis built the lead to 23 early in the third, but Brewer, who did not take a shot in the first half, nailed a trio of 3-pointers to bring Denver within 14 points.
"I never thought it was going to be a runaway, even when we were up 17, 18 points," Memphis coach Lionel Hollins said. "They are small and quick. They started making 3s, which they weren't doing in the first half."
Brewer would eventually collect 18 points in the period, hitting 6 of 9 shots, including going 5 of 6 from outside the arc.
That helped Denver chip its way back into the game, and when Lawson tipped in a miss in the closing seconds of the period, the Memphis lead was cut to 83-73 entering the fourth.
And, after Denver scored the first two baskets of the fourth, including a layup by Brewer, the 23-point lead was down to 83-77.
Faried had 10 points in the fourth.
"We didn't quit," Hollins said of holding on for the win. "We didn't give up, and we worked really hard for that win. I'm just happy. It was an exciting game and a great game for the Denver fans on TV, and it was a hairy win and a scary win for our fans.
"I just thank god we have the win."
NOTES: Nene missed his third straight game with a strained left calf. . Denver's 15 first-quarter points matched a Nuggets low for points in a quarter. They had 15 in the third quarter in Wednesday's loss to the Mavericks. . The Grizzlies are 7-0 when scoring 100 points.