LeBron James cramped up, but came through.

Russell Westbrook turned it on, then tuned out.

James knocked down a go-ahead 3 late in the fourth quarter Tuesday night and the Miami Heat moved within one win of the title with a 104-98 victory over the Oklahoma City Thunder in Game 4 of the NBA Finals.

After sitting on the bench with cramps in both legs, James checked back in to knock down the shot that put the Heat up for good and sent them to a 3-1 lead in the series.

"I don't know how he did it," said Chris Bosh, who watched as his teammate was carried off the floor during a timeout.

James sat wincing on the bench as Heat trainers attended to his legs. He said afterward that it felt like his body just shut down but he wanted to go back into the game.

His go-ahead shot came as the shot clock ticked off its final seconds.

"I just wanted to step up and try to make a play," said James. "If I was out on the floor I was just trying to make a play with the limited mobility I had."

James scored 26 points to lead Miami, while Westbrook poured in 43 for the Thunder, but made a costly error with 13.8 seconds left when he fouled Mario Chalmers with the shot clock winding down and his team down by three.

The Thunder now face a nasty bit of history: No team has ever come back from a 3-1 deficit in NBA Finals history.

Game 5 is Thursday in Miami.

Dwyane Wade and Chalmers added 25 points each for Miami, with Chalmers getting 12 in the fourth quarter. The Heat overcame a 17-point deficit in the first quarter for their third straight win.

Kevin Durant scored 28 for the Thunder.

James slipped in the lane midway through the fourth quarter, was slow to get up and remained on the Miami side of the floor to score a bank shot after a Wade block at the other end.

After he collapsed back to the floor he was helped to the bench.

Westbrook had scored 13 straight Thunder points to tie the game at 90 shortly before James went down. And while the Heat star was out, Durant made a jumper from the right side to cap an 11-2 Thunder run that gave them a 94-92 lead.

Heat coach Erik Spoelstra said the cramps didn't go away, but James came back and buried the 3 from the high right side to make it 97-94 Miami. Wade added a scoop layup, ending a quick 7-0 burst.

"That three was just sheer will and competitiveness," said Spoelstra.

James went out again with 55.5 seconds left -- they were still working on his legs during a timeout -- and didn't come back. But the shot he made was good enough. He added 12 assists and nine rebounds in the win.

"That's what being in these Finals is about," said Bosh, who had 13 points and nine rebounds, "giving it all you got until you can't walk anymore."

Chalmers put the Heat up by five with a layup. It was followed by Westbrook's quick bucket after another timeout, but the Thunder guard's mental mistake cost his team on the other end.

Haslem hustled for a loose ball after Wade missed a floater and the Heat got possession after a jump ball. With the shot clock re-set to 5 seconds, Miami had no good look. But Westbrook wrapped up Chalmers, and the Heat guard hit two foul shots for a five-point lead.

"Just a miscommunication on my part," Westbrook said. "Nothing I can do about it now."

Thunder coach Scott Brooks called it a "tough play" but stuck up for his point guard.

"One play doesn't decide a game," the coach said. "You learn from it and move on from it. ... He kept us in the game."

The Heat also led Dallas 2-1 last year but lost three in a row as the Mavs rallied for the title. James had just eight points in Game 4 last season but now is one win away from his long-awaited first title.

"It's still all business," said Chalmers. "We got one more win."

The Heat mounted a 19-2 run to come all the way back from a 17-point deficit in the first quarter, tying the game on Wade's 3 from the high left side early in the second. The run took just 4:24 and was highlighted by a pair of 3s from Norris Cole early on.

The Thunder had scored 33 points in the first quarter -- their best frame of the Finals so far -- including eight on the fastbreak as they ran the Heat up and down the court.

Cole knocked down a 3 for the first points of the second quarter while James and Wade followed with layups and James Jones hit a 3 to keep the run going.

Wade's 3 tied it at 35-35, ending the surge, but the Heat were never able to go in front. Shane Battier missed a 3 at the buzzer that would have tied the game at halftime.

The Heat took their first lead since 2-0 on a Wade jumper early in the third quarter that made it 50-49. Later, James scored eight straight points for the Heat to help them build a seven-point lead. The Thunder pulled within 79-75 going into the fourth quarter.

Game Notes

Heat president Pat Riley was named the Chuck Daly Lifetime Achievement Award winner by the National Basketball Coaches Association on Tuesday...Chalmers had 25 points after scoring just 17 in the first three games of the series combined.