Bradley Beal, leaning in to challenge the Bucks’ Brandon Knight for a loose ball in the first half, scored 12 of his 23 points in the fourth quarter to help Washington hang on after blowing a big lead in a 114-107 victory in Milwaukee. (Jeffrey Phelps/Associated Press)

The game was unraveling, a gigantic lead disappearing right along with their energy levels, and the Washington Wizards were in desperate need of a calming presence. It came from the youngest player on the roster. With all of the madness going on around him, Bradley Beal remained unshaken as he helped the Wizards avoid what would’ve been one of the most disappointing losses of the season to the Milwaukee Bucks.

After the Bucks had finally chopped down a 28-point first-half to just three, Beal answered with a driving a layup and then buried a three-pointer to secure a 114-107 victory at the BMO Harris Bradley Center. Beal scored 12 of his 23 points in the fourth quarter as the Wizards (33-29) won for the eighth time in nine games.

Trevor Ariza made five three-pointers and led the Wizards with a game-high 28 points, but after dominating for the entire the first half Washington left the floor feeling relief more than anything. John Wall had a poor offensive night, scoring just nine points on 4-of-14 shooting, but he handed out 13 assists and put the game completely out of reach when he buried a three-pointer to put the Wizards up 112-101 in the final minute.

“Any time you win, it’s a good win. No matter who you playing against, no matter where you’re playing,” Ariza said. “We are fortunate to get a win. It could’ve been a little bit prettier, but even ugly ones count. However you got to get it, you got to get it.”

The Bucks (12-50) have the NBA’s worst record but they have given the Wizards fits this season, pushing them to overtime in each of the first two meetings, with both teams winning on the road. When the teams met at Verizon Center on Dec. 6, the Wizards squandered a five-point lead with 51 seconds remaining in regulation before losing.

On Saturday, they looked like a team that had no interest in a tight contest as they hit from wherever they wanted and built a seemingly insurmountable lead. But somewhere along the way, the Wizards got too comfortable and a Bucks team that has taken its share of beatings refused to go down meekly. Brandon Knight led Milwaukee with 25 points, but the Bucks rallied behind reserves Ramon Sessions and John Henson, who combined for 26 points, including 20 in the second half.

Wall grabbed his first breather with 52.7 seconds left in the first quarter and the Wizards leading by just five points. The handoff from Wall to his backup has usually been followed by a significant dropoff, but Andre Miller came in and ran the offense as if he had been with the team for two years rather than a little more than two weeks.

Miller made a fallaway shot in the lane to barely beat the shot clock near the end of the first period to give the Wizards a 36-27 lead, then fed Drew Gooden for a jumper and a driving layup himself. A wily, crafty veteran who thrives on his brain over his physical gifts, Miller ran a clinic on the Bucks with his decision-making and old-school tricks.

After finding Martell Webster cutting to the basket for an emphatic one-hand dunk over Bucks rookie Giannis Antetokounmpo that brought the Wizards players out of their seats on the bench, Miller stole an a bad pass by John Henson. But instead of simply dribbling up the floor, Miller angled in front of Henson as he started to run and fell to the ground after drawing a foul. As his teammates rushed to pick him up, Miller flashed a huge grin.

Miller would continue setting up his teammates with sweet passes, as he hit Al Harrington in the right corner for a three-pointer and Gooden in the left corner for another. He then gave the Wizards a 54-33 lead when he hit a 16-foot set shot and grabbed a seat. In Miller’s seven-minute first-half stint, the Wizards outscored the Bucks, 24-9.

Wall returned to action refreshed and unburdened about needing to make up for lost time. He made an easy, uncontested driving layup and found Beal open for two three-pointers, the last one giving the Wizards a 71-43 lead. Beal made 5 of 8 from long range in the game.

“I was just staying aggressive,” Beal said. “It was a great feeling, whenever I can step up my game. We got too complacent. We’ve got to have more of a killer mentality of just putting teams away.”

A week after setting a season high with 74 halftime points, the Wizards entered the locker room with 75 — a number that they hadn’t reached in three entire games this season. Unfortunately for the Wizards, they stopped playing after Trevor Booker gave them a 25-point lead with 20.4 seconds remaining in the first half.

The Wizards followed a do-no-wrong half — in which they shot 67.4 percent from the field (29 of 43) and 58.8 percent from three-point range (10 of 17) — with a do-no-right third quarter in which they had more turnovers (seven) than field goals (four) and went more than seven minutes without scoring at all.

“We’ve got guys that need to learn that a game is never over in the NBA,” Coach Randy Wittman said. “We came out in the third quarter and played like we’re going to run the clock out and go on home. Played the exact opposite of what we did in the first half.”

Ariza finally ended the scoring drought when he made a driving layup to give the Wizards a 77-65 lead. Gooden extended the lead to 16 with a putback layup but the Bucks refused to back down.

The Wizards signed Gooden to his second 10-day contract earlier in the day and it worked out that the 11-year veteran got to face the team that discarded him last July using the amnesty provision. Out of work until the Wizards signed him to provide more depth in the absence of Nene and Kevin Seraphin, Gooden tried to downplay his return to Milwaukee, focusing more on the support he received from the fans. But his play revealed how much the game meant to him as he scored a season-high 13 points, his second consecutive double-digit scoring game.

The second unit provided 39 points, with Webster returning from a sore back to score 15 points and shoot 3 of 3 from long distance.