LeBron James grimaced and groaned, unable to play and unable to sit on the bench because of a throbbing pain in his right leg. James had been such a impactful force against the Oklahoma City Thunder, given so much of himself that he was too exhausted to finish. With the win within his grasp, James was forced to be a spectator for the final, unsettling 55.5 seconds of Game 4 of the NBA Finals.

With Russell Westbrook and Kevin Durant leading a furious charge, the Miami Heat was placed in a difficult position to hold on. But after letting James carry the team for most of the night — with his dominant presence inside and impeccable passing — the Heat lifted James to the finish with a gritty 104-98 victory that put the three-time league’s most valuable player within one victory of hoisting that elusive Larry O’Brien trophy.

“It’s a big-time team win, and we needed every point. We needed every rebound and everything that everyone had to get it,” said James, who has worn a mouth piece with XVI — the Roman numeral for 16 — to symbolize the number of postseason victories required to win a title. “If we come out with the mind-set that we’ve come out with during the playoffs, we’re going to give ourselves a good chance to win.”

Mario Chalmers matched a playoff career high with 25 points, including the final five points — a driving underhanded layup and three free throws — as Miami took a three-games-to-one lead over the Thunder. The Heat, a team built through free agency wizardry and James’s controversial defection from Cleveland, is close to capturing the first of the many titles James predicted during a smoke and laser introduction two years ago — and completing the exorcism of a disappointing loss to the Dallas Mavericks that lingered with them for more than a year.

Dwyane Wade also had 25 and Chris Bosh chipped in with 13 points and nine rebounds for the Heat, which has a chance to make sure that his series never goes back to Oklahoma City, with Game 5 on Thursday at American Airlines Arena.

“That’s what the Finals is about, giving everything you have until you can’t walk no more,” said Bosh, who joined forces with James and Wade in the summer of 2010 for this opportunity. “It’s about will. It’s about nothing else. . . . We know it’s not over until it’s over, so we have to finish this job that we started.”

James pulled up lame while falling on a drive to the basket with 5 minutes 49 seconds remaining and was forced to leave the game, getting to the bench with the assistance of reserve Juwan Howard, shortly thereafter. He returned with a limp, hobbling around the floor as he knocked down an inspiring three-pointer that broke 94-all tie, but he was forced to sit for good with a leg cramp about five minutes later after finishing with 26 points, 12 assists and nine rebounds.

Chalmers overcame a severe shooting slump, missing 16 of 18 shots dating back from Game 2 before finally breaking through and rescuing the team with 12 points in the final period — more than James and Wade combined (11).

“That’s the reason we all wanted to play together,” said Wade, who led Miami to its first championship in 2006. “It’s very hard in this league to win, to win it all. You’ve got to have guys that on any given night they can carry what you call your own weight and nights like that you’ve got to do it together.”

Westbrook had 43 points, including 17 in the fourth quarter, and Durant had 28 but the Thunder is on the brink of elimination after squandering a 17-point first-quarter lead and again foundering with late blunders.

Westbrook made a bank shot to bring Oklahoma City within 101-98 with 40.5 seconds remaining. Reserve James Harden forced a jump ball with Udonis Haslem, Haslem’s tip would have gone out of bounds had Battier not saved it and gotten the ball to Chalmers. Westbrook fouled Chalmers with 13.8 seconds remaining, though the Heat only had about one second remaining on the shot clock.

“It was just a miscommunication on my part,” Westbrook said. “Nothing I can do about it now.”

The Heat realized that the best way to keep Durant from scoring was to keep him from getting the ball entirely. Battier consistently shielded Durant from the ball, forcing the Thunder to get offense from elsewhere and the relentless Westbrook was more than willing to take control and silence the critics who have pounced on him throughout this series. He scored 11 consecutive points for the Thunder, refusing to give in after the Heat took a 90-83 lead on a Wade three-pointer.

Westbrook responded with a driving layup and beat his chest after drawing a foul, then he hit a pull-up jumper and made two free throws to tie the score.

“It’s all about my team and us winning a game,” said Westbrook, who rebounded from a performance in Game 3, which his poor resulted in him being benched for a critical stretch in the third quarter of the Thunder’s 91-85 loss. “It’s not me against the world. It’s not the world against me. It’s me and my teammates trying to win.”

James stumbled and fell while driving around Durant and lost the ball to Derek Fisher. Fisher kept the ball to himself on a four-on-two fast break and Wade blocked the shot, leading to James scoring a layup on the other end. James immediately asked to be taken out, as he limped up the court and collapsed to the ground.

“I knew I wasn’t injured,” James said. “I just knew I had cramps. I’ve had it before. Your muscles basically just lock up on you, so I tried to walk, but they wasn’t letting me move.”

James rested during the timeout but James Jones stepped on the floor in his place. As James sat on with his knees on a towel, the Thunder took a 94-92 lead when Durant made two free throws. James went to the scorers’ table and the crowd cheered until he was finally able to enter the game with 4:05 remaining. Miami scored the next seven points and never looked back, even as its best player was forced to look on.

“Frustrating to lose like that,” Durant said. “But we’re going to keep fighting, man. That’s who we’ve been since I got here. . . . We’ve got to keep believing, and that’s what I’m going to keep doing. That’s the message I’m going to feed to the guys. Me and Russell are going to tell them to keep believing, and next game is a must-win.”