AUBURN HILLS, Mich. -- Dirk Nowitzki made two big shots down the stretch to lift Dallas to an important win.
Afterward, he was still shaking his head.
"This is one we'll take, but got to be better," he said. "We got lucky."
The Mavericks blew a 15-point lead in the fourth quarter but recovered to beat the Detroit Pistons 102-99 on Friday night. Charlie Villanueva missed a 3-pointer in the final seconds that would have tied it, and Dallas pulled within 3 1/2 games of eighth-place Utah in the race for the last playoff spot in the Western Conference.
Detroit took a 97-96 lead on a 3-pointer by Khris Middleton, but Nowitzki answered with an 18-footer from the right side and a 15-footer from the left, putting Dallas ahead by three.
It was 100-99 after Villanueva caught teammate Jose Calderon's airball and made a layup with 6 seconds left. Darren Collison hit two free throws for the Mavericks, and Villanueva missed from the left corner.
"We did not do a good job in the fourth, but we held them off and got the win and that is a positive," Mavericks coach Rick Carlisle said. "We made a couple mistakes on that last play. We blew the coverage, but we got lucky."
It was the opener of a four-game road trip for the Mavericks that might represent their last chance to start making up ground and extend their streak of playoff appearances to 13 seasons. O.J. Mayo scored 22 points, going 5 of 8 from 3-point range. Teammate Mike James was 4 of 6. Dallas shot 11 of 21 from beyond the arc.
Brandon Knight scored 21 points for the Pistons. Detroit coach Lawrence Frank missed his second straight game because of a personal matter, and assistant Brian Hill filled in.
"The only thing I can say is after being very disappointed with our effort in the first half defensively and the game-plan mistakes we had, I thought our guys took the challenge in the second half and gave us a much better effort defensively," Hill said. "We got a couple good looks at the end. They didn't fall."
Down 88-73 in the fourth, Detroit started its rally by scoring six straight points. The Pistons were still down 95-88 when Middleton and Villanueva made consecutive 3-pointers to set up a tense finish.
Brandan Wright scored 14 points for the Mavericks, and Nowitzki and James added 12 each.
Greg Monroe had 14 points and 10 rebounds for Detroit. Middleton, a rookie who was taken in the second round of last year's draft, scored a season-high 14 points. He'd scored 37 all season prior to the game.
"Everyone wants to play in the fourth quarter, because that's money time," Middleton said. "I have confidence in my shot, and so do my teammates, so I was going to take it when I got an open look. That's my job."
Dallas led 76-71 after three quarters, then started the fourth on a 12-2 run capped by two 3-pointers by Vince Carter. Knight then missed a layup while alone on a fast break, and it looked as though the Mavericks would have little trouble closing out the game.
It turned out Detroit had one more run left, but the Pistons still lost for the seventh time in eight games.
"They are a resilient team," Carlisle said. "They have young guys that have turned into fighters. Lawrence and Brian Hill have done a great job with them and they are going to get better and better."
Dallas now plays at Minnesota, Milwaukee and San Antonio. The Mavericks are in the middle of a stretch in which they play seven of eight on the road. ... Detroit's Kyle Singler went crashing into the scorer's table after being fouled near midcourt in the final seconds of the third quarter. He made two of three free throws to cut the deficit to five.