NEW YORK (AP) — The Minnesota Timberwolves have won the NBA draft lottery, the first time since 2004 the team with the worst record won the No. 1 pick.

After years of bad luck in the lottery, things finally worked out Tuesday night for the Wolves, who will have the top pick to put next to Rookie of the Year Andrew Wiggins.

The Los Angeles Lakers moved from the fourth spot to second, keeping a pick they would have sent to Philadelphia if it fell outside the top five. The 76ers are third followed by the New York Knicks, who had the second-best odds of winning but instead fell to fourth 30 years after winning the first draft lottery and drafting Hall of Famer Patrick Ewing.