The Grizzlies (35-18) limited Gay to 13 points, one of his lowest outings since joining Toronto last month, en route to a fifth straight victory that strengthens their bid for homecourt advantage in the play-offs.
"It was a battle by both teams and eventually it became a game down to the wire," Memphis head coach Lionel Hollins said.
"We made a lot of plays, got stops, got big rebounds, made plays at the offensive end and also made just enough free throws."
Zach Randolph had a team-high 17 points for the Grizzlies, who tightened their grip on fourth place in the NBA's Western Conference and improved on the franchise's best start to a season through 53 games.
Memphis took a nine-point lead into the final quarter and then had to withstand a fourth-quarter rally by the Raptors (22-33) that was not enough to give the home side their first six-game winning streak since 2009.
Alan Anderson came off the Toronto bench to score a game-high 19 points, including four three-pointers during the final quarter as the Raptors tied the game with about four minutes left in regulation.
But the Grizzlies prevailed in the end, due in large part to their ability to shut down Gay, who entered the game averaging 21.1 points a game since joining the Raptors.
Gay made just five-of-15 attempts, collected a team-high nine rebounds and had a game-high five turnovers.
"They are not chopped liver defensively," Raptors head coach Dwane Casey said after his team were limited to 36.6 per cent shooting in the loss.
"(Gay) was going to have to work for his shots. Mentally, we have to be ready for that type of fight at the beginning of the game so we get that rhythm early."
- Sports & Recreation