"Rudy is good at that," Randolph said. "I knew it was good when it left his hand. He's good at shots like that and he's hit a lot of them."
Gay drove right and put up a 14-foot fadeaway jumper over Toronto's Julian Wright.
The play was similar to his last-second game-winner over LeBron James that gave the Grizzlies a 97-95 home victory over the Miami Heat on Nov. 20.
"I predominantly go left so people have to give me the right," Gay said. "It's all confidence though. That's all it's about really."
Toronto's losing streak is its longest since a 10-game slide from March 26 to April 12, 2006.
"It's tough," Bayless said. "Rudy just hit a tough shot. Julian did the best he could."
Randolph shot just 8 for 24, but extended his team-record streak of double-doubles to 11 games.
The Raptors finished 0 for 13 from 3-point range and failed to make a 3 for the first time in 986 games, a streak that began Feb. 26, 1999, against Minnesota. The Raptors are the first team in NBA history to make a 3 in 900 consecutive games.
"It's not the main focus but it was nice to have," Bargnani said of the streak, which had covered his entire career.
|More on Grizzlies at Raptors|
|Facts & Rumors|
Toronto trailed 88-76 with 8:28 to play but roared back with an 11-0 run over the next 3½ minutes. DeRozan hit a jumper, Bargnani made two free throws and followed with a jump shot, Johnson had a layup and Bargnani finished the run with a three-point play, making it 88-87 with 5:13 left.
DeRozan gave Toronto its first lead of the fourth quarter by making a pair of free throws with 3:58 left, putting Toronto up 92-91.
Conley put Memphis back on top with 2:10 left. After making one free throw but missing the second, Conley wound up with the loose ball and drove in for a layup to make it 96-94.
After a pair of free throws by DeRozan and a running jumper from Conley, Bayless tied it at 98-98 on a driving layup with 18 seconds left.
Memphis gave the ball to Gay, who let the shot clock wind down before driving for the winning basket.
"I just wanted to make sure there were no seconds left on the clock," Gay said, "make sure nobody could square up and actually be ready to shoot the basketball at the other end."
Memphis coach Lionel Hollins said he knew he wanted the ball in Gay's hands.
"With so much time on the clock, I knew I was going to give it to him to go get us a shot," Hollins said. "He's the one guy on our team that can get a shot, make the shot but also get a really good shot. I thought about throwing the ball in the post, but I knew they were just going to come and double and collapse. I figured if I wanted one guy to take the shot, it would be Rudy."
Toronto inbounded the ball to Sundiata Gaines, but Gay blocked his shot attempt as the buzzer sounded.
"We're finishing like a playoff team," Conley said. "We're making the right passes, making the right plays and getting the big stops when we need them."
Sonny Weems was scoreless in eight minutes for Toronto after not playing the previous 18 games because of back spasms. Weems last played Dec. 15 against Chicago.
The Raptors led 20-11 with four minutes left in the first, but Mayo scored seven points off the bench as Memphis rallied to take a 25-24 lead after one.
Tony Allen scored eight points in the second quarter and Gasol had seven, but Bargnani answered with eight to keep the Raptors close. Memphis led 51-49 at the half.
Gay scored eight points in the third, including a 3-pointer with five seconds left, and Randolph had six as Memphis took an 80-74 lead into the fourth.
- Toronto signed Gaines to a second 10-day contract.
- The Raptors acquired C Alexis Ajinca, a future second-round draft pick and cash from Dallas in exchange for the draft rights to F Giorgos Printezis .
- Former NFL running back Jerome Bettis attended the game.