Kevin Love scored 28 points and grabbed 11 rebounds for Minnesota, which got 24 from Chase Budinger, 15 from Gorgui Dieng and 13 apiece from JJ Barea and Ricky Rubio, who also added 14 assists. Referee Ken Mauer called the last foul on Miami's Norris Cole, saying he hit Brewer on a pass into the paint.
Ray Allen missed a wild jumper as time expired for Miami, which blew a chance to move two games clear of Indiana in the loss column atop the Eastern Conference standings.
But Brewer got the call on the next Minnesota possession, and his free throw was the difference.
Miami went 24 for 30 from the line, but three of those six misses were costly. James missed one of two free throws with 16.2 seconds to go, and Chalmers missed the first of two on his trips to the line in the final seconds of both regulation and the first overtime.
The Heat (52-23, .693) remained percentage points ahead of Indiana (53-24, .688), which lost earlier Friday night at Toronto, 102-94.
Regulation and the first overtime ended in virtually the same fashion. With Minnesota up by one and Miami in desperation mode, Chalmers would make the second of two free throws - with 3.9 seconds left in the fourth, then with 1.9 seconds left in the first extra session - to tie the game, followed by the Heat watching a potential winning jumper by Love bounce off the rim.
There were nine lead changes in the entirety of regulation. There were 10 in the first OT alone.
Budinger's fifth 3-pointer of the night put Minnesota up 107-106 late in the first extra period. Bosh fought for an offensive rebound on the next Miami possession, wound up getting fouled and coolly making a pair of free throws to give the Heat a one-point edge.
Minnesota called its next play for Love, who backed Bosh down and connected on a jump hook to reclaim that one-point lead. But Chalmers wound up drawing another foul, hit the second shot and off to double-overtime they went.
By then, it was obvious that whichever team lost was going to have a long night of lamenting missed opportunities.
Minnesota had a six-point lead early in the fourth, but a pair of 3s on consecutive possessions by Allen - who returned from a five-game absence brought on by a nasty bout with the flu - tied the game at 82-all.
That's when James went to the bench for a quick breather. When he returned, the Heat were down by five, and Minnesota's lead was seven with 3 minutes left in regulation.
Bosh wasn't deterred. He made a pair of free throws, had a key block and hit a 3-pointer to get the Heat within 93-91 with 1:58 left. Chalmers scored four of Miami's final six points of regulation, and Love had a stepback 3-pointer rim out as regulation time expired.
For a team not going to the playoffs, Minnesota had plenty of poise.
James made a jumper over Brewer to get Miami within 60-56 early in the third. But by the time that basket was even announced, the Timberwolves answered with one of their best weapons - the fabled Love outlet pass. Love grabbed the ball as James' jumper fell through the net, then quickly fired about an 80-foot pass to a breaking Brewer for a dunk that restored Minnesota's six-point lead.
Minnesota led by nine later in the third before James scored Miami's last 12 points of the period.
NOTES: Miami was again without Dwyane Wade (hamstring) and Greg Oden (back spasms). ... It was Rubio's first time playing at Miami. ... Minnesota was again without C Nikola Pekovic (ankle), who has missed 21 of the Timberwolves' last 31 games. ... A foul by Budinger saved Minnesota two points late in the third; he hit James on a play where Allen made a 3-pointer. After review, Allen's 3 was correctly taken off the board and James only made one of his two ensuing free throws.