The supreme court on Monday struck down a federal law that bars gambling on football, basketball, baseball and other sports in most states, giving states the go-ahead to legalize betting on sports.

The supreme court ruled 6-3 to strike down the Professional and Amateur Sports Protection Act. The 1992 law barred state-authorized sports gambling with some exceptions. It made Nevada the only state where a person could wager on the results of a single game.

One research firm estimated before the ruling that if the supreme court were to strike down the law, 32 states would probably offer sports betting within five years.

Sign up to receive the top US stories every morning

“The legalization of sports gambling requires an important policy choice, but the choice is not ours to make. Congress can regulate sports gambling directly, but if it elects not to do so, each state is free to act on its own. Our job is to interpret the law Congress has enacted and decide whether it is consistent with the constitution. Paspa is not,” Justice Samuel Alito wrote for the court.

The court’s decision came in a case from New Jersey, which has fought for years to legalize gambling on sports at casinos and racetracks in the state.

More than a dozen states had supported New Jersey, which argued that Congress exceeded its authority when it passed the 1992 Professional and Amateur Sports Protection Act, barring states from authorizing sports betting. New Jersey said the constitution allows Congress to pass laws barring wagering on sports, but Congress can’t require states to keep sports gambling prohibitions in place.

All four major US professional sports leagues, the NCAA and the federal government had urged the court to uphold the federal law. In court, the NBA, NFL, NHL and Major League Baseball had argued that New Jersey’s gambling expansion would hurt the integrity of their games. Outside court, however, leaders of all but the NFL have shown varying degrees of openness to legalized sports gambling.

The American Gaming Association estimates that Americans illegally wager about $150bn on sports each year.

The 1992 law at issue in the case bars state-authorized sports gambling with exceptions for Nevada, Montana, Oregon and Delaware, states that had approved some form of sports wagering before the law took effect. Nevada is the only state where a person can wager on the results of a single game, though the law doesn’t cover wagering between friends. The law also doesn’t cover animal races, such as horse racing, which many states already allow.

New Jersey has spent years and millions of dollars in legal fees trying to legalize sports betting at its casinos, racetracks and former racetracks. In 2012, with voters’ support, New Jersey lawmakers passed a law allowing sports betting, directly challenging the 1992 federal law which says states can’t “authorize by law” sports gambling. The four major professional sports leagues and the NCAA sued, and the state lost in court.

In 2014, New Jersey tried a different tactic by repealing laws prohibiting sports gambling at casinos and racetracks. It argued taking its laws off the books was different from authorizing sports gambling. The state lost again and then took the case to the supreme court.