MILWAUKEE - Khris Middleton executed the winning play just like he wanted.

Middleton's driving layup with less than 10 seconds remaining carried the Milwaukee Bucks to a 96-95 victory over the Dallas Mavericks on Friday night.

"I was just trying to get to the rim and make a play happen," Middleton said after scoring 27 points.

His last two were set up by a huge defensive stop John Henson made on Dirk Nowitzki.

Nowitzki scored 20 points, including two free throws with 38 seconds left for Dallas' first lead since early in the first quarter. After Giannis Antetokounmpo was called for an offensive foul, Dallas worked the ball to Nowitzki, but Henson blocked his pass and it deflected to Middleton, who raced down the court and scored.

"Dirk kind of threw a low pass and, fortunately, I was there to deflect it," Henson said. "Khris made a great play at the end."

The Bucks scored 20 points off 16 Dallas turnovers, but the last one hurt the most.

"A bad turnover on my part there. We're up one," Nowitzki said. "I saw Zaza (Pachulia) flash in there and thought I could get it to him in the lane. He could swing it maybe for a good shot on the weak side. Henson's long and he got his arm on it."

Deron Williams missed at the buzzer for Dallas.

"We got a good look for the win, in my view," Nowitzki said. "I'll take that all day. It just didn't go."

Henson scored 16 points and Michael Carter-Williams added 15 points and a season-high 12 rebounds as Milwaukee snapped Dallas' six-game winning streak against them.

Devin Harris came off the bench for a season-high 19 for Dallas.

Nowitzki, Williams, Pachulia and Wesley Matthews all returned after sitting out a 100-91 win at New Orleans on Wednesday. They were rested after all had played 40-plus minutes in a 117-116 double-overtime win over Sacramento.

Milwaukee clung to a single-digit lead for most of the fourth quarter until consecutive 3-pointers by Raymond Felton tied it at 90 with 4:20 left to play.

Both teams missed several scoring chances down the stretch before Felton fouled Middleton, who made one of two free throws for a 94-93 lead.

Dallas came out with more energy in the third quarter and erased the Bucks' first-half lead that had been as much as 17 points. Nowitzki capped a 12-2 run with a 3-pointer that pulled the Mavericks to 57-51 before the Bucks called time with 9:42 left in the third quarter.

Milwaukee controlled the low post, scoring almost at will and led 55-39 at the half. Dallas had 12 points in the paint, but the Bucks had 34, including an alley-oop dunk by Henson on a perfect pass from O.J. Mayo that pushed the lead to 17 points.

Middleton scored 17 points, making 7 of 11 shots from the floor, in the half and Henson added eight in the second quarter.

THREE FOR ALL

Dallas finished with an NBA season high-tying 44 3-point attempts and set an NBA season high for a half with 26 3-point attempts in the first half.

TIP-INS

Mavericks: After a brief review, Williams was called for a flagrant foul 1 when he hacked Carter-Williams on a drive to the basket with 5:38 left in the third. Carter-Williams made one of two free throws. ... Dallas came out flat and shot 6 for 20 (30 per cent) from the floor in the first quarter. ... The Mavericks had no points in the paint through the first nine minutes of the first quarter, while the Bucks had 16.

Bucks: Milwaukee converted 10 Dallas turnovers into 15 points in the first half. ... Jerryd Bayless was out for the second consecutive game after missing 12 of the previous 17 with a left ankle sprain. ... Coach Jason Kidd watched the game from the privacy of his Bradley Center office. He is recovering from hip surgery. ... Miles Plumlee missed the game with a sore left knee.

UP NEXT

Mavericks: Visit Minnesota on Sunday.

Bucks: Visit New York on Sunday night.