The Grizzlies trailed by 21 in the third quarter and were down 16 entering the fourth. Gay helped the Grizzlies take over down the stretch. He threw down a thunderous dunk and then hit the contested jumper to make it 87-85.
The Sixers were on the brink of a shot-clock violation when the ball bounced out of bounds. Sam Young made up for a boneheaded basket in the first half with a jumper for a four-point lead and the Grizzlies held on.
Zach Randolph had 22 points and 12 rebounds for the Grizzlies.
The Sixers were too late when they tried to pull off a comeback of their own. Tony Battie's 3-pointer with 8.3 seconds left made it 93-90 and Jodie Meeks tossed in a long 3 and drew the foul with 7.1 seconds left. With Sixers chairman Ed Snider standing from his courtside seat, Meeks sank the free throw to pull the Sixers to 95-94.
Randolph, who made 10 of 11 free throws, hit two from the line and Philadelphia's errant inbounds sailed out of bounds and into the Sixers bench. Randolph capped the win with two more from the line and sent the Sixers to their latest crushing defeat.
Meeks and Jrue Holiday each scored 16 points for the Sixers. Elton Brand had 15 points and nine rebounds.
The Sixers appeared to bust the game open when they hit four 3-pointers during a 21-2 run early in the third quarter.
Unlike some of their recent wins, when reserves such as Lou Williams and Thaddeus Young were counted on for big buckets in the second half, the Sixers' starters took over the in the third. Meeks and Andre Iguodala combined for 17 points and the Sixers shot 52 percent.
Meeks hit three 3s during the run and the Sixers made eight straight shots during the spurt.
It should have been enough.
The Grizzlies' reserves sparked a 15-3 run that trimmed the lead to 76-68, but Meeks answered with his fourth 3 of the game. Iguodala went behind the back on the break to Young for a one-handed jam that made it 84-74 with 5:12 left.
The Grizzlies, chasing the eighth seed in the West, started chipping away and left the Sixers wondering where it all went wrong.
Memphis played without guard O.J. Mayo, serving the first game of a 10-game suspension without pay for violating the league and union's anti-drug program with a positive test.
The Grizzlies have to be relieved they didn't lose by two. Williams missed a jumper late in the first half and Young was alone under the basket to make the grab. But the ball knocked off his right hand and straight through the hoop.
Brand was closest to the basket and credited with the points.
It proved a costly mistake when the Sixers led the Grizzlies 44-40 at halftime.
That embarrassment came a day after the league suspended Mayo for a positive test for dehydroepiandrosterone (DHEA). He blamed an over the counter supplement that he didn't know was banned by the NBA for the positive test, but declined to say which supplement he used. He will be able to return Feb. 15, also against the 76ers in Memphis.
One Sixers fan held a sign that read: ``Our bench doesn't need DHEA to perform.''
Fan, follow and download: Get the latest from NBCPhiladelphia.com anytime, anywhere. Follow us on Twitter, Facebook and NBC Philadelphia. Sign up for our sports newsletter. And, get breaking news delivered right to your mobile phone -- just text PHIBREAKING to 639710 to sign up. (Message and data rates may apply.)