MIAMI (AP)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 was Miami on Tuesday night.

The Heat 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,” 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.”

Here’s 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.

”We won,” Butler said. ”Complete team effort. I’m proud of my guys.”

Max Strus scored 22 points and Victor Oladipo had 19 for Miami. The Heat were without four regular starters – Tyler Herro, Bam Adebayo, Kyle Lowry and Caleb Martin – because of injuries.

Shai Gilgeous-Alexander scored 26 points for the Thunder. Giddey finished with 18 points, 15 rebounds and 10 assists, getting the triple-double on an assist setting up Aaron Wiggins’ dunk for a 111-106 lead with 1:28 left.

Miami scored the final six points.

”Whatever it takes to win,” Butler said.

Miami led 89-88 going into the fourth, and with Butler on the bench – he had played the entire third quarter – the Thunder took advantage. They scored the first six points of the final period, taking their first lead of larger than three points when Tre Mann connected on a jumper with 9:20 left for a 94-89 lead.

But a six-point possession gave Miami the lead back. Oladipo made a steal and Thunder center Eugene Omoruyi was called for a clear-path foul. Oladipo made both free throws, and on the continued Miami possession, Gabe Vincent made a 3-pointer while getting fouled by Mann. Vincent made the free throw, and just like that, a 96-91 deficit was a 97-96 lead.

”We always talk about finding a way to win. … This is a good start to that,” Butler said.

TIP-INS

Thunder: Oklahoma City reached the midway point of this season at 18-23. Even without the injured No. 2 pick Chet Holmgren, it’s progress – the Thunder were 15-21 at the midpoint of the 72-game season two years ago, and 14-27 midway through last season. … Gilgeous-Alexander had 15 of his points in the final 6:26 of the second quarter, after having only two points previously.

Heat: Udonis Haslem was the only available Heat player who didn’t get into the game. … Orlando Robinson started at center for Adebayo, making him the 13th player to start for Miami this season and the 202nd to start a game in team history.

MANY LINEUPS

Oklahoma City used its 20th starting lineup of the season in 41 games. Miami used its 18th in 42 games.

”I think there’s a hidden benefit to kind of some instability in your rotations and in your lineups,” Daigneault said. ”It forces your own team to become very adaptive and to really not make excuses … and I think it becomes hard to adjust to.”

UP NEXT

Thunder: At Philadelphia on Thursday night.

Heat: Host Milwaukee on Thursday night.

AP NBA: https://apnews.com/hub/nba and https://twitter.com/AP-Sports