Denver's Ty Lawson had 29 points, nine assists and six rebounds and hit several key shots, including a running bank shot to send the game into overtime tied at 92-92.
Gallinari struggled from the field as he shot 7 of 20 for the Nuggets. Kenneth Faried had 14 points and 12 rebounds for Denver.
Garnett was 3 of 4 from the field in overtime after missing 14 of his previous 20 shots.
With Denver leading 105-104 in the second overtime, Lawson hit another jumper to put the Nuggets up 107-104 with 18.9 seconds remaining.
But Pierce hit a 3-pointer with Miller in his face with 5 seconds left to tie it at 107.
Gallinari then had an open lane to the basket as he was overplayed by Garnett, but missed his shot as time ran out.
Green's 3-pointer tied the game at 99 with 23.8 seconds remaining in the first overtime, but Lawson's long 3-pointer fell short at the buzzer.
Denver failed to hit its last shot in all three overtimes with chances to win the game in the first two and to tie it in the third.
Green's jumper put Boston ahead 92-90 with 47.9 seconds remaining in regulation. Miller then missed consecutive shots on the ensuing Denver possessions, but Faried was fouled with 5.4 seconds remaining.
Faried missed both free throws, but Celtics guard Avery Bradley knocked the ball out of bounds. Lawson then scored with 0.8 seconds remaining.
Gallinari, who averages 20 points per game to lead Denver, was held to three points in the first half on 1-of-6 shooting as the Nuggets trailed 50-46 at the break.
Notes: Pierce and Lawson each played 54 minutes respectively. ... JaVale McGee had 16 rebounds for Denver. ... Boston is 13-2 in its past 15 home games against Denver, but the teams are 10-10 head-to-head in the past 20. ... Boston matches up again on the road with Denver on Feb. 19. ... This had been the Nuggets' longest winning streak since March 30 to April 15, 2005. ... Andre Iguodala left the game for Denver in the third quarter and did not return.