The Supreme Court cleared the way Monday for states coast to coast to legalize betting on sports, breaking a longtime ban and creating a potential financial boon for states and the gambling industry. The first bets could be placed within weeks.

Despite opposition from the major sports leagues and the Trump administration, the high court struck down a federal law that had barred betting on football, basketball, baseball and other sports in most states. States that want to take advantage of the ruling now will generally have to pass legislation to allow sports books to open. Some, including New Jersey, which brought the case to the Supreme Court, have a head start.

Sports leagues had expressed concerns about any expansion of sports gambling. Their huge businesses could be badly harmed if people thought the outcome of games could be altered by someone who had wagered money on a certain result.

However, the ruling also could be seen as merely bringing an activity out of the shadows that many people already see as a mainstream hobby. Americans wager about $150 billion on sports each year illegally, according to the American Gaming Association. The law the justices struck down forbade state-authorized sports gambling with some exceptions and made Nevada the only state where a person could wager on the results of a single game.

Stock prices for casino operators and equipment makers surged after the ruling was announced.

Gambling on sports could quickly become widely available, with one research firm estimating that 32 states would likely offer sports betting within five years.

The ruling "opens up the floodgates" for sports gambling in any state that wants to have it, said Daniel Wallach, a sports law expert in Florida.

The decision had been eagerly anticipated by gamblers and also states that hope their cut of legalized sports betting can help solve budget problems. States that have already laid the legal groundwork include New Jersey, where one racetrack said it would begin taking bets within two weeks. Mississippi and West Virginia have also been preparing for sports betting, and gamblers there could be placing bets as early as this summer and certainly before the NFL season starts in September.

Delaware, too, could quickly expand beyond certain bets currently offered at its casinos. Pennsylvania and New York have also made moves to begin sports gambling. However, other states that want to allow sports betting could still see several Super Bowls come and go before people there can place a legal bet close to home.

The Trump administration had urged the high court to uphold the law, surprising perhaps because the president is the former owner of a New Jersey casino, the Trump Taj Mahal, now being remade into a Hard Rock casino resort. All four major U.S. professional sports leagues and the NCAA also had urged the court to uphold the federal law, saying a gambling expansion would hurt the integrity of their games. They also said that with legal sports betting in the United States, they'd have to spend a lot more money monitoring betting patterns and investigating suspicious activity.

Sports gambling proponents argued that the leagues already do that work and that legal sports betting will make enforcement easier than it is now, when most bets in the U.S. are made illegally. They say state regulators are capable of monitoring suspicious bets, as is done in Nevada.

On Monday, NBA commissioner Adam Silver and Major League Baseball issued statements saying the "integrity" of their games would remain a priority. Representatives of the National Hockey League, National Football League and NCAA said they were reviewing the court's decision.

Some saw other concerns, including for some gamblers. The ruling "will likely increase gambling participation and gambling problems unless steps are taken to minimize harm," said Marlene Warner, the president of the National Council on Problem Gambling's board of directors. The council said any government body or sports league that receives a direct percentage or portion of sports betting revenue should dedicate some of it to treat gambling problems.

The law the justices struck down was passed by Congress in 1992 and called the Professional and Amateur Sports Protection Act.

Justice Samuel Alito wrote for the court, "The legalization of sports gambling requires an important policy choice, but the choice is not ours to make." The court's "job is to interpret the law Congress has enacted and decide whether it is consistent with the Constitution," he wrote. "PASPA is not."

Justices Ruth Bader Ginsburg, Stephen Breyer and Sonia Sotomayor dissented. Ginsburg wrote for the three that when a portion of a law violates the Constitution, the court "ordinarily engages in a salvage rather than a demolition operation," preserving what it can. She said that instead of using a "scalpel to trim the statute" her colleagues used "an axe." Breyer agreed with the majority that part of the law must be struck down but said that should not have doomed the rest of the law.

Congress could try to step in again. Sen. Orrin Hatch said he would soon introduce legislation to set national standards for sports betting, but It is unclear whether the rest of Congress will want to join him.

The ruling was a particular victory for New Jersey, which has fought for years to legalize gambling on sports at casinos and racetracks. Former Republican Gov. Chris Christie tweeted that it was a "great day for the rights of states and their people to make their own decisions." The state's current governor, Democrat Phil Murphy, said he was "thrilled" to see the high court strike down the "arbitrary ban." Several hours after the Supreme Court ruled, New Jersey lawmakers introduced new legislation that would regulate and tax sports gambling in the state.

Casinos and racetracks in the state are also moving quickly. Monmouth Park, a racetrack at the Jersey Shore, has already set up a sports book operation and said Monday it plans to start taking bets within two weeks "unless someone stops us." And Tony Rodio, president of Tropicana Entertainment, said his Atlantic City casino will offer sports betting once it can get it up and running.

"It's been a long time coming," he said.