Jason Terry added 16 points and Caron Butler contributed 11 points and eight rebounds to help the Mavericks to their fifth straight win over the Pistons.
Nowitzki went 13 for 23 from the field, hitting all three of his 3-point attempts, and converted 13 of 16 free throws.
"It was winning time and the big German was hot," Terry said. "He was tremendous. It never ceases to amaze me the way he's able to fill it up."
The Mavericks erased a 12-point second-half deficit. Nowitzki scored 15 and went 8 for 8 from the line in the final quarter, but Terry's nine points and Butler's seven in the last 12 minutes also were crucial.
Butler had Dallas' first six points of the fourth quarter to fuel the comeback.
"Caron got us started with some drives," Nowitzki said. "We really had to grind this one out. It wasn't pretty for a while, but [Terry] got hot there at the end and made some big baskets."
The Mavericks were lethargic for much of the night before picking up their energy level down the stretch.
"It was a slower-paced game, a playoff-style game," Mavericks coach Rick Carlisle said. "But we found a way to get it done. It isn't always going to be pretty."
Nowitzki scored nine straight, capped by an 18-footer with 5:29 remaining for a 75-70 lead.
Terry hit jumpers on consecutive possessions for an 83-78 advantage with 2:35 left.
Richard Hamilton helped Detroit rally, making two free throws with 1:01 left to trim Dallas' lead to 84-82. Terry missed a long jumper, but Nowitzki pulled down the rebound, then drained four foul shots in the final 18.9 seconds to seal the victory.
Detroit held a 61-56 advantage after three quarters, with Nowitzki's 27 points keeping Dallas close.
But the Pistons faded at crunch time, going 7 for 18 from the floor and getting outrebounded in the final quarter, 13-6.
"This is a tough loss because we controlled the game pretty much throughout," Prince said. "We knew it would come down to Jason Terry and Dirk making plays at the end. It's a tough combination to try to stop."
The Mavericks, opening a stretch of four games in five nights, came out strong, but they couldn't sustain it.
Dallas rolled to an 11-0 lead in the first 4 1/2 minutes, capped by Nowitzki's 3-pointer. Detroit missed eight of its first nine field goal attempts with two turnovers as Dallas went up by as many as 14.
The Mavs led by seven after the first quarter but the Pistons outscored them 25-14 in the second to take a 42-38 halftime lead. Nowitzki had 17 points at the break, but none of his teammates could chip in with more than four.
The Pistons also will be busy during the holiday season as they entered a stretch of six games in nine nights.
Dallas' 14-point second quarter was its lowest of the season for that quarter. ... The Pistons held a 16-5 rebounding edge in the second even with team rebounding leader Ben Wallace spending the quarter on the bench. ... Dallas F Shawn Marion missed the morning shootaround with an illness, and was able to play only 15 minutes, scoring four points. Carlisle said Marion should be fine for Wednesday night's game at Oklahoma City.