Mike Conley had 11 points and a career-high 14 assists for the Grizzlies, who picked up their first road win since Nov. 6 at Sacramento. They had dropped their previous six away from home.
Gay sent the game to overtime with a 3-pointer just before the regulation buzzer that tied it at 92. Gay's 22-footer from the left corner was his only 3-point attempt of the game.
Randolph, who made 15 of 19 shots from the field and also had 17 rebounds, had the key basket in OT, making a turnaround bank shot to give Memphis a 98-96 lead with 2:30 left. Goran Dragic missed a 3-pointer on the other end and Gay hit two free throws to extend the lead to four.
After Steve Nash made a driving layup, Randolph connected on a jumper with 8.7 seconds left and O.J. Mayo hit two free throws to finish the scoring.
Dragic led the Suns with 17 points. Hedo Turkoglu added 15 and Nash and Channing Frye had 11 apiece. But Nash also had eight turnovers.
Memphis carried a 78-64 lead into the fourth quarter but the Suns stormed back to tie it at 86 on Turkoglu's 3-pointer with 2:48 remaining. Turkoglu added a tiebreaking 3-pointer with 6.2 seconds left.
Conley and Frye each went 1 for 2 from the free-throw line before Gay came up with the big shot.
Darrell Arthur finished with 12 points and 10 rebounds for Memphis, which shot 49 percent from the field. The Grizzlies also had 23 assists, compared to 16 for the Suns.
Grant Hill and Hakim Warrick had 10 points apiece for the Suns, who trailed 53-41 at halftime. Phoenix went 17 for 27 from the foul line.
NOTES: The Suns and Grizzlies each had 47 rebounds. ... Memphis went 18 for 22 from the foul line.