The result had major short-term ramifications in the Western Conference playoff race, with Golden State (38-36) not only moving 1 1/2 games up on Dallas (36-37) but also gaining a tiebreaker advantage by claiming the season series 2-1.
Jonathan Kuminga had a team-high 22 points off the bench, Draymond Green and Stephen Curry hit key hoops down the stretch for the Warriors.
The game was tied at 120-all when Green drove into the heart of the Dallas defence and dropped in a layup while getting fouled by Christian Wood with 1:32 to play.
After Green completed the three-point play, the Mavericks countered quickly with a Wood hoop to get within one, then got an opportunity to take the lead after a missed 3-pointer by Donte DiVincenzo.
But Luka Doncic misfired on a 3-pointer, after which Curry drove for a layup that allowed Golden State to build the lead back to three with 8.5 seconds left.
After another Doncic miss, this on a layup attempt, Kevon Looney dropped in two clinching free throws with 1.7 seconds left as the Warriors finished a five-game trip with consecutive wins after losing the first three games.
The tightly contested game, in which neither team led by more than nine points, saw the Warriors go up 113-105 on a Kuminga dunk with 6:35 remaining.
But Dallas, seeking to avoid a second straight loss, stormed back immediately with two 3-point hoops from Jaden Hardy and an interior basket from Doncic in a 54-second flurry that forged a tie and set up the exciting finish.
Curry finished with 20 points and a team-high 13 assists for the Warriors, who prevailed despite shooting just 12-for-39 on 3-pointers and getting outscored 51-36 from beyond the arc.
Looney also recorded a double-double with 12 points and a game-high 12 rebounds, while Jordan Poole finished with 16 points, and Green and DiVincenzo 14 apiece.
In his return from a five-game absence due to a strained thigh, Doncic paced the Mavericks with 30 points while also finding time for a game-high 17 assists and a team-high seven rebounds. He shot just 11-for-27 overall and 2-for-10 on 3-pointers, however.
Reserves Hardy and Wood had 27 and 19 points respectively for the Mavericks, who were missing Kyrie Irving, out with a sore right big toe. Reggie Bullock chipped in with 15 points, Dwight Powell 13 and Josh Green 12.
(With inputs from Reuters)
For all the latest Sports News Click Here
For the latest news and updates, follow us on Google News.