Kevin Garnett had 26 points and 11 rebounds and Paul Pierce scored 19 points as visiting Boston took a 3-2 lead in the Eastern Conference finals.
Mickael Pietrus and Ray Allen added 13 points apiece for the Celtics, who notched the first road victory in the best-of-7 series.
LeBron James had 30 points and 13 rebounds and Dwyane Wade scored 27 points for Miami, which looks to avoid elimination when the series returns to Boston for Game 6 on Thursday.
Miami’s Chris Bosh returned from injury and had nine points and seven rebounds in 14 minutes off the bench.
The Celtics overcame a nine-point third-quarter deficit and took the lead for good on two free throws by Pierce with 1:34 remaining.
Pierce added a contested 3-pointer over James to give the Celtics a 90-86 lead with 52.9 seconds left. James pulled the Heat within 92-90 on a driving basket with 9.4 seconds to play before Garnett hit two free throws with 8.8 seconds left to provide the final margin.
Boston outscored Miami 15-1 over the final six minutes of third quarter to take a 65-60 lead into the final stanza.
A 3-pointer by Pierce gave Boston a six-point lead with just over 11 minutes left before Miami went on a 16-4 run to take a 78-72 lead on Wade’s driving basket with 6:16 remaining.
Udonis Haslem had 14 rebounds for Miami and Rajon Rondo had 13 assists for Boston.
Bosh entered the contest with 5:06 left in the first quarter and had nine points and six rebounds in the first half. Bosh had missed nine games since suffering a strained lower abdominal muscle on May 13 against the Indiana Pacers.
The Celtics never led until Pietrus drained a 22-footer with 48.6 seconds left in the third quarter.
Miami led by as many as 13 points but Boston outscored the Heat 18-7 over seven-plus minutes to pull within two late in the half. The Heat led 42-40 at halftime.
GAME NOTEBOOK: James has three double-doubles in the series and six in the postseason … Rondo set a Celtics franchise record with his 39th career double-digit assists game in the playoffs, passing Hall of Famer Bob Cousy’s mark. … Bosh came off the bench for the first time since 2003 when he was a rookie with the Toronto Raptors. … The Celtics had 13 steals, led by four from Rondo. … Miami had a 49-39 rebounding edge. … Pierce was 6 of 19 from the field.