LAKE BUENA VISTA, Fla. — Listless and uninspired, the Los Angeles Lakers meandered through another sloppy first half in Game 4 of the NBA Finals.

They discovered a purpose in the second half offensively and defensively to beat the Miami Heat 102-96 on Tuesday for a 3-1 series lead.

LeBron James scored nine points in the final 6:08 and 20 of his 28 points in the second half when the Lakers needed an offensive spark. He also had 12 rebounds and eight assists. Anthony Davis had 22 points and nine rebounds, and Kentavious Caldwell-Pope finished with 15 points and five assists.

The Lakers are on the verge of their first championship since 2010 and their 17th overall, which would tie them with the Boston Celtics for most in NBA history. James is also one victory from his fourth championship and third with three teams.

“This was a throwback game and there were some moments of truth there at the end, and probably the bottom line is they won those moments of truth,” Heat coach Erik Spoelstra said. “We had some reads, they are long and they are an extremely good defensive team. Windows have to be much quicker. I thought we had some opportunities.

“But you do have to credit their defense and they just made some more plays going down the stretch. We’ll respond. That’s academic at this point. We’ll just rest up (Wednesday) and get back to work and get ready for the next one.”