Boston could not put the game away after opening a 15-point lead in the third period and although the Celtics never trailed, they did not clinch it until Lee hit two foul shots with 4.1 seconds left for a five-point advantage.
O.J. Mayo scored the final point of regulation from the free throw line with 52 seconds left and his layup with 11 seconds to go in the first overtime again created a tie.
The game took almost 3 1/2 hours to play and included 192 field goal attempts. Dallas hit 51 percent of its shots, but the Mavericks were thwarted by 27 turnovers that included 16 steals from the Celtics.
Dallas had a three-game winning streak snapped.
Pierce scored 34 points, but he missed 14 of his 25 shots from the field. Kevin Garnett and Rajon Rondo both had 16 for Boston.
The Mavericks put seven players in double figures and Mayo led the way with 24 points. Darren Collision had 20, but the last of his seven turnovers prevented Dallas from getting off a potential game-tying 3-pointer in the closing seconds of the second overtime.
Notable deaths of 2014 [PHOTOS]