Gay hit a fadeaway jumper over James at the buzzer, and the Memphis Grizzlies took advantage of Dwyane Wade's absence to beat the Miami Heat 97-95 on Saturday night and snap a five-game losing streak.
James tied it for the 12th time, dunking off Eddie House's steal of Gay with 5.5 seconds left. Gay came back with the winning 13-foot jumper in front of the Heat bench. Officials reviewed the shot, then ruled it beat the clock.
"I don't care if James Naismith was guarding me, which would be scary because he's dead," Gay said. "I really don't care who's guarding me to be honest with you."
That winning shot was bittersweet for Gay.
"I love the fact that I made a shot, but the turnover kind of tainted that feeling," Gay said.
Miami coach Erik Spoelstra said only a few players can get that shot off against James.
"He was pursuing with everything he had," Spoelstra said of James. "He got a really good contest on it and have to give Rudy Gay credit. He had a very difficult shot."
James said he was on Gay's hip the whole time and used his length to contest the shot. He said he felt Gay got out of control, bobbling the ball a bit.
"So it allowed me to once again get back in front of him," James said. "If he misses that shot, it's great D, we're going to overtime. If he makes it it's a great shot ... that was the best D we could have had."
The Heat now are 2-3 when playing away from Miami, and 0-1 without Wade this season. He sprained his left wrist Friday night. The injury woes mounted when Udonis Haslem went down with 1:25 left in the third quarter and had to be carried off the floor to the locker room with a sprained left foot. X-rays were negative, and he will be re-evaluated Sunday.
James said Haslem dislocated his second toe and tore a few ligaments. Chris Bosh said they all know it's not a good sign when someone is carried off the court.
"Unfortunately the game goes on," Bosh said.
James finished with 29 points and 11 assists, and House had a season-high 20 as the Heat lost for the first time in four games. Bosh also had 20.
Miami last led after James' three-point play made it 90-87 with 3:09 left. Mike Conley hit a long jumper as the Grizzlies reeled off eight straight points, capped by Gay's layup with 38.5 seconds left.
Bosh responded by hitting a 3, then House stole the ball from Gay for the tying dunk.
"This was the most unified we've been," Hollins said. "That's how you win tough, close games, everybody rooting for each other, everybody picking each other up."
Darrell Arthur and rookie Xavier Henry started in their place, and Arthur had 12 of his 14 points in the first quarter as the Grizzlies took the lead from the opening bucket and were up as much as 11.
Randolph led Memphis with 21 points and 13 rebounds. Conley had 16 points, Gay 15, and Marc Gasol 11. Randolph blocked James' layup with 58.9 seconds left.
"I blocked LeBron," Randolph said. "It's for me, one of the biggest plays of the game. It wasn't bigger than Rudy's shot though. That game-winner. There wasn't nothing bigger than that."
With Randolph helping the Grizzlies outrebound 47-32 and outscore the Heat in the paint, Spoelstra disagreed a bit.
"He probably had as much of an impact on this game as anyone," Spoelstra said.
Wade's fever that had him questionable Friday night broke. Spoelstra sat him because the guard hurt his left wrist during Friday night's 95-87 win over Charlotte back in Miami, even though his X-rays were negative as well. It's the first game Wade has missed since a calf injury kept him out of three games in February.
The Heat opened by missing their first five shots and were just 7 of 21 in the first quarter as Memphis lead 26-17 and 43-39 at halftime.
Randolph had only two points and one rebound in the first half. Mayo entered the game with 10:13 left in the second quarter. It took both quite a while to get going before the Grizzlies' second sellout crowd this season with plenty of fans wearing Heat jerseys.
James, booed at times, spent much of the first half distributing the ball to his teammates. He had almost as many assists (seven) as points (10). He tied it for the second time at 43 with a three-point play in the third quarter, and the Heat didn't lead until James hit two free throws with 6:49 left in the third at 53-52.
The teams wound up swapping the lead 20 times in the second half with 11 ties.
The Heat are 40-64 without Wade and 270-213 with him. ... The Heat had a season-low 12 free throw attempts, half the previous low of 24 against New Orleans on Nov. 5. ... Jerry Stackhouse started for the first time since Nov. 1, 2008, when he was with Dallas against Minnesota. ... Mayo snapped a streak of 177 consecutive starts, which was behind only the Lakers' Derek Fisher (304) and Luis Scola of Houston (215). ... This was the earliest Memphis has had two sellouts since the 2005-06 season. ... Heat forward Juwan Howard, who broke his nose Wednesday against the Phoenix Suns, did not play against Charlotte on Friday. But he got into the game in the third. ... Former NFL receiver Isaac Bruce helped shoot T-shirts into the crowd during a timeout in the fourth quarter.
Heat's Josh Richardson and Hornets Cody Zeller both have monster blocks, one after the other in the second quarter.
The Rockets have been portrayed as having major chemistry issues, but their GM says the issue has been overstated by outsiders.
Kyle Lowry throws the alley and Jonas Valanciunas finishes with a two-handed oop in the second quarter against the Pacers.