The New Orleans Pelicans blew several leads on Tuesday night against the Milwaukee Bucks.

Fortunately for them, they didn’t at the game’s end.

Getting a pick on Pelicans forward Anthony Davis, Milwaukee forward Ersan Ilyasova missed a wide open 3-point attempt at the buzzer, and New Orleans escaped with an 85-84 win at the Smoothie King Center.

“They had an open shot to win the game, but somehow it went in and out,” Davis said. “We defended, we rebounded, and guys hit big shots. But we’ve go to learn how to put teams away.”

It was an appreciated ugly win for the Pelicans (37-30), who got back into a tie with idle Oklahoma City for the Western Conference’s eighth and final playoff spot with 15 games to go.

It gave New Orleans the 2-0 season sweep of the Bucks (34-33), who are in the Eastern Conference’s sixth playoff spot.

How ugly was the win? New Orleans shot 34.9 percent, including 4-of-20 in the fourth quarter, and Milwaukee hit 37.2 percent. After the first quarter, the Pelicans had four stretches of seven or more missed shots.

Western Conference Player of the Week Davis, who had torched the Bucks for a career-high-tying 43 points on 17-of-23 shooting on March 9 in Milwaukee, led the Pelicans with 20 points but shot just 6-of-18.

Davis did have 12 rebounds, and Omer Asik had 11 to go with 16 points, as the Pelicans, who lost in double overtime to Denver on Sunday, avoided an ill-afforded second consecutive home loss.

Davis sank a baseline jumper with 1:07 left that gave the Pelicans an 85-82 lead. However, after Tyreke Evans’ driving shot was blocked, Jerryd Bayless was fouled on the break by Davis and sank two free throws with 34.5 seconds left.

Eric Gordon then missed on a drive, and the Bucks called timeout with 9.7 seconds left.

The teams were tied at 80 with 2:16 remaining after Ilyasova’s putback.

New Orleans had led 75-70 at 5:54 of the fourth and 71-64 at the 10-minute mark.

After an embarrassing second quarter, the Pelicans had more urgency in the third quarter and went into the fourth with a 70-62 lead.

By 9:06 of the third, they’d scored 12 points, surpassing their second-quarter total, and led 56-47 at 8:19 after Asik scored five consecutive points.

But Milwaukee stormed back behind wiry power forward John Henson, who scored six points and blocked two shots in lifting the Bucks to a tie at 56.

However, Quincy Pondexter sank a 3-pointer, and the Pelicans outscored the Bucks 14-6 the rest of the way. New Orleans led 63-62 with 2:01 showing but ended with a 7-0 burst highlighted by a 3-pointer by Norris Cole.

Davis, after being shut out in the second quarter, scored eight in the third.

The Pelicans trailed 44-42 at halftime after scoring just 10 points on 3-of-22 shooting — an incredible 13.6 percent — in the second quarter. And that was a complete about-face from how the game began.

Obviously intent on shaking off their gut-wrenching loss to Denver on Sunday, the Pelicans started the game with much focus and intensity, bursting to a 15-0 lead by the 7:28 mark.

Determined to improve their defense against drives to the basket after the Nuggets thrashed them for 64 points in the lane, the Pelicans picked up the Bucks higher on the perimeter and applied much pressure. It resulted in a 0-of-8 Milwaukee shooting start.

Meanwhile, Eric Gordon got the Pelicans started with a 3-pointer, Tyreke Evans began driving and Davis making jump shots.

Milwaukee adjusted. Overall, it began playing more aggressively, with physicality and intensity defensively and exploiting the high defense by driving forcefully to the lane, particularly Antetokounmpo.

The quarter ended with the Pelicans leading 32-21, but the Bucks made eight of their final 13 shots.

An 8-0 run to start the second brought them to 32-29, and by the 6:05 mark, the Bucks had tied the score at 35, mostly behind their very physical defense. Key was their length, with Carter-Williams, 6-7, hounding Gordon and Antetokounmpo, 6-11, working over Davis. Neither Pelican scored in the second quarter.

The Pelicans shot 55.0 percent (11-of-20) in the first quarter.

Notes

Forward Ryan Anderson, out since Feb. 21 with a sprained right knee, was fitted for a brace that he’ll begin wearing next week rehab, he said. The prognosis is for him to return Saturday, but he said he’s not close to playing again. The has begun jogging and on Tuesday began working on his lateral movement. … ESPN listed Davis as the NBA’s most unlikely player to be traded.