MILWAUKEE (AP) — Giannis Antetokounmpo scored on a driving layup with two seconds left to give Milwaukee a 127-125 victory over the Charlotte Hornets on Wednesday night, the Bucks’ eighth consecutive victory.

Antetokounmpo had 40 points and 12 rebounds and Khris Middleton added 21 points for the Bucks.

LaMelo Ball had a career-high 36 points for the Hornets, followed by Kelly Oubre Jr. with 25 and Miles Bridges with 22 points.

Middleton buried a 3-pointer from the top left to put Milwaukee in front 123-122 with 52 seconds left. Antetokounmpo’s lay-in on the Bucks’ next possession was negated by an offensive foul.

Gordon Hayward missed a jumper from the top of the key for the Hornets, and Middleton hit two free throws to make it 125-122 with 8.6 seconds remaining.

Ball made a fadeaway 3-pointer — his eighth of the game — with 5.9 seconds left to pull the Hornets even at 125. After a timeout, Jru Holliday fed Antetokounmpo near the top of the lane for the left-side layup.

Charlotte made 10 of 17 from beyond the arc in the opening quarter, and Oubre’s 3-pointer in the closing seconds put the Hornets up 41-25 entering the second period. Oubre had 20 points in the first half, making 5 of 7 3-pointers. Hill’s 3-pointer from the left corner brought the Bucks within 68-60 at the half.

Milwaukee took its first lead at 91-90 on a three-point play by George Hill with 2:25 left in the third quarter.

TIP-INS

Hornets: Charlotte entered last in scoring defense at 114.9 points per game and was without two of its better inside defenders, F Cody Martin (illness) and C Mason Plumlee (right calf strain).

“We’ve got to be a much better defensive team. We understand that. It’s no secret,” coach James Borrego said. “The bottom five teams defensively just don’t win consistently in this league. I’ve never seen that. Top-tier defenses do. That’s our goal.”

Bucks: With C Brook Lopez sidelined since the opener (back soreness), Milwaukee signed veteran free agent DeMarcus Cousins, who was available Wednesday night. The 6-foot-10 Cousins averaged 8.9 points, 6.4 rebounds, and 17.4 minutes in 41 games last season with the Houston Rockets and Los Angeles Clippers.

Cousins played 14 minutes, scoring seven points. Bucks coach Mike Budenholzer said before the game that he thought Cousins is “mentally … in a good place, so we’re excited about having him for, whatever this is, 60 games or so.”

UP NEXT

Hornets: At Atlanta on Sunday.

Bucks: At Toronto on Thursday.