The defending NBA champion Mavericks have won three in a row for the first time this season, and climbed above .500 after dropping their opening three games.
Dallas took a 15-6 lead, saw its advantage trimmed to one at halftime and then built a 13-point advantage late in the third period.
Boston came back to tie it midway through the fourth and again deadlocked the game at 85-85 on Paul Pierce's 3-pointer with 25 seconds left. It was his first field goal since the opening period.
Nowitzki then drove to the basket and despite being fouled hard by Brandon Bass managed to make his layup attempt. He converted the ensuing free throw and Boston's Ray Allen then fumbled the ball out of bounds.
Jason Terry made a layup just before the buzzer to clinch the victory.
Terry had 18 points while Nowitzki had 16 points and seven rebounds. Boston, which dropped its second straight after winning four in a row, was led by Rajon Rondo with 24.
Dallas Coach Rick Carlisle was ejected from the game early in the second half, drawing two quick technical fouls after running onto the floor to argue that Nowitzki was fouled on a play on which no whistle blew.