Brandon Jennings scored 31 points, including three 3-pointers in a critical stretch of the fourth quarter, and Milwaukee beat Miami 105-97 on Wednesday night for the Bucks' second win over the Heat this season.

Jennings also had eight assists while Drew Gooden added 17 points and nine rebounds for the Bucks, who have won three straight.

LeBron James scored a season-high 40 points, including a highlight-reel windmill dunk at the end of his huge first quarter. James had 24 points in the first quarter, the most points any player has scored in a quarter this season, according to STATS LLC.

Dwyane Wade added 23 points for the Heat, but it wasn't enough to beat a Bucks team that also recently knocked off the Los Angeles Lakers.

Bucks fans chanted "overrated" in the final minutes of the game.

Milwaukee trailed 60-47 at the half but closed the gap in the third quarter.

Jennings' 3-pointer cut Miami's lead to 62-60 with 8:25 left in the third, and the Heat went into the fourth with a 79-76 lead.

Ersan Ilyasova converted a three-point play to tie the score at the start of the fourth, and Jennings hit a running layup to give the Bucks an 81-79 lead with 11:06 left.

Milwaukee's fourth-quarter run continued, and the Bucks led 87-82 when Luc Richard Mbah a Moute scored inside. The Heat than drew a shot-clock violation with the ball in James' hands, and Jennings hit a 3-pointer on the other end to give Milwaukee a 90-82 lead with 6:40 to go.

After a pair of free throws by Gooden, Wade missed a contested layup, and Jennings hit another 3-pointer.

James missed a long jumper — and Jennings drilled yet another 3, giving the Bucks a 98-82 lead.

With Milwaukee later leading 101-92, James was called for traveling in transition with just over two minutes left.

The Bucks beat the Heat 91-82 in Miami on Jan. 22, Miami's lowest scoring output of the season. But the Heat didn't have Dwyane Wade for that game because of a sprained right ankle, and the Bucks did have Andrew Bogut.

Now Wade is back, and Bogut will be out until at least late March with a left ankle fracture.

Milwaukee has played well without Bogut, the No. 1 pick in the 2005 draft. Coming into Wednesday's game, Milwaukee had won three of its last four — including a home win over the Lakers last Saturday.

Stephen Jackson returned for the Bucks, after serving a one-game NBA suspension in Milwaukee's victory over the Los Angeles Lakers on Saturday, then being benched by coach Scott Skiles in the Bucks' victory over Detroit on Monday.

Wednesday's game had all the makings of a Heat blowout early on, thanks to James. Already off to a sizzling start, James finished the first quarter in memorable fashion.

With under a minute left in the quarter, he took the ball away from Milwaukee's Beno Udrih, took a couple of steps and finished with a powerful windmill dunk with 32.9 seconds left in the quarter.

As if that wasn't enough, James then hit a 3 with 2.2 seconds left in the quarter.

James' huge dunk drew a gasp, then a roar from the crowd. It even had a pair of Bradley Center ushers recreating the dunk during the first-quarter break.

James' first-quarter total surpassed his own previous best for a quarter when he had 22 in the first against New Jersey on Jan. 7. It matches James' career high in a quarter, accomplished three previous times.