Pierce finished with 15 points and Joe Johnson added 14 for the Nets, who won their season-high eighth straight at home. Brooklyn moved three games behind Toronto in the Atlantic.
Kyle Lowry scored 21 points to lead Toronto, which had won three straight and nine of its previous 11. Tyler Hansbrough and Amir Johnson added 16 points each.
The Nets played their sixth straight game without Kevin Garnett, who was in the starting lineup but was scratched minutes before tip-off.
The Nets trailed 94-92 after Lowry split the defense in the lane for a lay-up with 2:15 left.
Brooklyn then answered with five straight points as Andray Blatche's reverse lay-up tied the score at 94 and Pierce followed with his 3 with 1:14 left.
DeMar DeRozan then beat Livingston to the basket but was fouled and made two free throws to pull to 97-96 with 1:03 to go. On Brooklyn's next possession, Williams drove to the lane but his shot was blocked by Johnson, setting the stage for a go-ahead or game-tying shot.
However, Terrence Ross lost control of the ball and Pierce, who wasn't sure if he was going to play today, came up with the steal.
Livingston hit two free throws to extend the Nets' lead to 99-96 with 22.8 seconds left. Lowry had a chance to tie with a 3 but missed. Blatche was then fouled with 6.5 seconds left and was only able to hit the second free throws to push the lead to four points.
As the Raptors proceeded to move the ball up the court, Lowry was fouled. He hit the first shot to make it 100-97 with 5.2 left. He purposely missed the second one but was called for a lane violation.
Pierce, who exited Sunday night's game in the first quarter with 10:45 left due to a sore right shoulder, then hit two free throws to seal the win and even the season series between both teams at two games apiece.
Brooklyn trailed 30-19 at the end of the opening period but had a strong second quarter, pulling to 51-50 at the half.
Down 60-59 after a tip-in shot by Jonas Valaciunas in the third quarter, Johnson and Williams each hit two 3-pointers to spark Brooklyn on a 14-0 run, leading 73-60 with 4:28 left.
But the Raptors answered with an 11-0 run over the next 3 minutes, capped by two free throws from Hansbrough.