NEW YORK — Dirk Nowitzki kept Dallas ahead with his consistent play, and J.J. Barea put away the Mavericks' win with a burst at the end.

Nowitzki had 23 points and nine rebounds, Barea scored 20 and the Mavericks beat the Brooklyn Nets 111-104 Sunday.

The Mavericks led 94-92 with more than five minutes left before Barea scored nine straight Dallas points.

"Big shots," Nowitzki said. "That's what he does, pick-and-roll. They came off there and he made a couple from mid-range. He kind of iced it for us there and he's made big plays for this franchise for a long time."

Said coach Rick Carlisle: "That was a key part of the game."

"I thought Dirk played a great game. His scoring and shooting was tremendous," he said.

Harrison Barnes added 19 points for the Mavericks. After Barea's surge, Barnes' two layups made it 107-101 with 26.5 seconds remaining.

Brook Lopez scored 27 points and Spencer Dinwiddie had 18 for the Nets. Randy Foye and Quincy Acy each had 11.

Barnes scored 15 points in helping the Mavs take a 57-43 lead at halftime. Lopez scored 12 in the third quarter, and Brooklyn trailed 82-72 heading into the fourth.

TIP-INS

Mavericks: Carlisle discussed Yogi Ferrell's impact since signing with Dallas. "We were all banged up. We had a lot of guys out. We desperately needed a guy that could play the position and hold the fort. I wasn't sure he was going to be a starter right away, but the way we were structured at the time it seemed like the best way to go. He started the first game, did a lot of good things and had a really terrific first couple of weeks. Now, we're at a point where he's pretty much held that position and he's done a lot of good things." Ferrell scored eight vs. the Nets. ... A.J. Hammons and Jarrod Uthoff were inactive.

Nets: Coach Kenny Atkinson thinks Rondae Hollis-Jefferson can be a power forward long-term. "I think four can be his main position. I also think he can play three. Obviously the perimeter shooting has to get better. I think he can play three because he can handle the ball and he can play a little bit of pick-and-roll. He's going to be that hybrid that I think is an important position." . Lopez played in his 550th game, tying Mike Gminski for second place on the franchise's all-time games played list. . Archie Goodwin made his Nets debut, becoming the 21st player to suit up for Brooklyn this season. He hit his only 3 try and finished with four points. ... Joe Harris (sprained left shoulder) and Sean Kilpatrick (strained left hamstring).

LIN HURT

Brooklyn's Jeremy Lin sprained his right ankle on a drive to the basket and missed the remainder of the game after being subbed out at the 4:35 mark of the first quarter. He had four points.

UP NEXT

Mavericks: Host Golden State on Tuesday, starting a four-game homestand.

Nets: Host Detroit on Tuesday. Brooklyn remains home for its next two games.