The Nets rallied in the fourth quarter to capture their fourth in a row and halt the Celtics' winning streak at three.
Boston outscored Brooklyn by 14 points in the third period to take a five-point advantage into the final period.
The Nets moved in front by four heading into the final minute, but the Celtics' Jeff Green hit a 3-pointer to get Boston within one with 58 seconds to go.
Brooklyn then started a parade to the foul line with Williams going 6-of-6 and Joe Johnson hitting 3-of-4 down the stretch to protect the lead.
It was the fourth win in five home games for Brooklyn since the Nets moved into their new arena at the start of this season.
Rosie O'Donnell unveils nearly 50-pound weight loss
Putin thinks Obama would save him if he were drowning