The Raptors raced to a nine-point advantage early in the fourth period only to go scoreless for more than 4 minutes while Memphis was staging its comeback.
Gay put the Grizzlies in front for good with 26 seconds left and scored 23 points. Gasol and Mike Conley had 21 points each.
Memphis won its third straight and kept the Raptors from posting back-to-back victories for the first time in five weeks.
Lytro unveils camera that can focus a photo after shooting it
Moore to attend retreat in to avoid Kutcher's wedding