– Jimmy Butler took the last free throw of the night, then bent his knees a bit and almost seemed unsure what would happen as the ball made its way to the rim.

Turns out, it was perfect — and so were the Miami Heat on Tuesday night.

They set an NBA record by making all 40 of their free throws, the last of those coming on Butler’s three-point play with 12.9 seconds left, and rallied in the final moments to beat the Oklahoma City Thunder 112-111.

Miami topped the 39-for-39 effort by Utah against Portland on Dec. 7, 1982.

“It’s just a normal Tuesday night for the Miami Heat,” coach Erik Spoelstra said. “I think this is when we feel most alive, when everything just happens and when all of our competitive juices get out there. That’s the team we all can relate to. That’s the team I like.”

Just some of what happened Tuesday: The Heat played without six injured players, including four starters; backup Heat center Dewayne Dedmon was ejected after arguing with his own team and smacking a massage gun onto the court during play from the sideline; Miami had a six-point possession in the fourth quarter; and Josh Giddey had a triple-double for the Thunder.

Oh, and the record from the line.

“Credit them, first of all, for that,” Thunder coach Mark Daigneault said. “That’s impressive.”

Butler scored 35 points and was 23-for-23 from the line, tying the second-most makes without a miss in NBA history. James Harden made 24 without a miss for Houston on Dec. 3, 2019, and Dirk Nowitzki made 24 without a miss for Dallas in a playoff game against the Thunder on May 17, 2011. Dominique Wilkins also went 23-for-23 in a game in 1992.