The Spurs won their 50th game of the campaign thanks to 28 points and 19 rebounds from Duncan, who because of a sore knee sat out last Tuesday's stunning loss to Minnesota.
San Antonio held an eight-point lead with 2:30 to play, but the Mavericks scored the last seven points of the game.
Vince Carter, however, misfired on a 3-pointer with a second to play.
San Antonio wrapped up a playoff spot for the 16th straight season. Gary Neal added 16 points for the Spurs and Kawhi Leonard had 12.
Dallas had been riding a season-best, four-game winning streak. Nowitzki led the Mavericks with 21 points and 11 rebounds.