The Mavericks made up a 14-point first-half deficit and the teams battled on even terms for most of the final two periods in a rematch of last year's Western Conference second-round playoff series.
After Dirk Nowitzki brought Dallas within two by scoring on a tip-in with 31 seconds to go, the Lakers' Pau Gasol was fouled by Brendan Haywood. Gasol missed both free throws but Barnes was there for the clutch rebound and he was promptly fouled by Jason Kidd.
Barnes hit the two free throws for a 95-91 lead and Derek Fisher added a foul shot with 6 seconds left for the final margin.
Nowitzki produced 25 points and 12 rebounds.