After months of breathless anticipation — and a race to the bottom of the standings by several teams — the New Orleans Pelicans shocked everyone by winning the N.B.A. draft lottery on Tuesday night, giving them the No. 1 pick in a draft that will include one of the most acclaimed prospects in league history: Duke’s Zion Williamson.

For the Pelicans to win the lottery, the three teams with the worst records this season — the Knicks (17-65), the Cleveland Cavaliers (19-63) and the Phoenix Suns (19-63) — had to lose again. They each came into the night with a 14 percent chance of getting the top pick in a revamped system designed to reduce the value of finishing at the very bottom. The Knicks ended up with the No. 3 pick, the Cavaliers with No. 5 and the Suns with No. 6.

New Orleans was tied for the seventh-best chance of getting the first pick — at just 6 percent — after finishing the season with a 33-49 record. Though not among the teams that appeared to tank for draft position, the Pelicans had trouble focusing all season because of drama surrounding a trade demand from their signature star, Anthony Davis. The question of what to do now about Davis — and possibly the rights to Williamson — will undoubtedly captivate the league in the lead-up to the draft at Barclays Center in Brooklyn on June 20.

Regardless of whether New Orleans stays at No. 1 or trades the pick, the top choice in the draft will almost assuredly be used on the 18-year-old Williamson, a player who has received as much attention as any amateur since LeBron James went straight to the N.B.A. from high school in 2003.