It looked like Miami was on the verge of snapping its eight-game losing skid after Eddie House made two free throws to open an 83-82 lead with three seconds to play.
But after the Celtics called a timeout, Pierce took the inbounds pass and drove past three defenders before time ran out.
The Heat have lost nine in a row for the first time since a 10-game slide from Dec. 1-21, 1990.
Eddie Jones again carried Miami's scoring load with 27 points on 8-of-19 shooting. He has led the Heat in scoring seven times during the losing streak and eight times this season.
But Jones was 1-of-5 from the field in the fourth quarter, when Miami shot just 3-of-18.