Denver scored 48 points in the paint, while holding the Grizzlies to a season-low 30 points, but neither team shot well from 3-point range with Denver hitting 3 of 16, while Memphis managed 5 of 19.
Memphis held a seven-point lead in the first half, but needed a jumper from Bayless in the final second to hold a 37-36 advantage entering the locker room.
McGee gave the Nuggets their first lead of the game on a dunk with 8.1 seconds left in the half.
Gay led Memphis with 10 points at the break, but the game was rather sloppy as Memphis shot 39.5 percent from the field, compared to 45 percent for Denver. The two teams were a combined 3 of 15 from outside the arc.
No Denver players were in double figures at the half, and Gallinari, who had hit 14 of 23 against Dallas, was scoreless, missing all three of his shots.
That slump ended immediately at the start of the second half as Gallinari connected on a 3-pointer, but he would not score his other field goal until the closing seconds.
The game settled into a close affair after halftime with seven lead changes and five ties in the third quarter.
The night ended with 12 lead changes and nine ties.
With some expecting the Grizzlies and Nuggets to be jockeying for playoff positioning at the end of the season, the win was important for Memphis. Denver had won the two previous meetings this season and a third would have given the Nuggets the potential tiebreaker.
"It was just important to get a win," Hollins said when asked about losing three to the Nuggets. "I don't think (Denver) specifically mattered, they just happened to be the opponent. We had lost two in a row, and we needed to get back to playing our game."
NOTES: Gay returned after missing Memphis' last game on Wednesday with flight problems getting back to Memphis after the Christmas holiday. ... The Grizzlies play five of their next six games on the road. ... Memphis G/F Quincy Pondexter was carried off with an apparent knee injury late in the third quarter. He did not return. ... Even with the loss, Denver has won 14 of the last 20 in the series. ... Denver is now 13-3 when holding opponents under 100. .Marreese Speights led Memphis with 10 rebounds, including six off the offensive glass, the first time this season he has led the Grizzlies in rebounds.