Ethan Miller via Getty Images The case is based on a New Jersey law that repealed the state's ban on wagering at racetracks and casinos.

The state of New Jersey has suffered defeat after defeat in its five-year effort to legalize sports gambling at the state’s horse tracks and casinos.

But on Monday, a majority of justices on the U.S. Supreme Court signaled that they may be ready to give New Jersey the only win it needs and pave the way for legalized sports gambling there and elsewhere in the United States, too.

At issue in the case, known as Christie v. NCAA, is a 2014 New Jersey law that repealed the state’s bans on sports wagering at racetracks and casinos. New Jersey’s effort took specific aim at the Professional and Amateur Sports Protection Act, or PASPA, a federal law Congress approved in 1992 that prohibits states, except for Nevada, from legalizing and regulating sports wagering. The NCAA and all four major professional sports leagues, all of which oppose the New Jersey law, sued the state and Gov. Chris Christie in an attempt to stop it, setting up years of legal wrangling that led, unexpectedly, to the Supreme Court this week.

Despite its implications for sports gambling, New Jersey’s argument rests not on the question of whether the increasingly popular practice should be legal. Instead, it relies on legal doctrine that limits the federal government’s ability to compel states to take certain actions on its behalf. New Jersey’s lawyers, led by former U.S. solicitor general Theodore Olson, argued before the hearing and in front of the court Monday that PASPA violates this “anti-commandeering” doctrine because it, in effect, prohibits states from changing their own laws and forces states to enact and enforce a policy on Congress’ behalf (the federal government, even under PASPA, does not ban sports gambling. It just bans states from legalizing it.)

In effect, that argument turned the case into a dispute over how much control the federal government can exert over states, making it “perhaps the most important federalism case the Supreme Court has heard in years,” Daniel Wallach, a gambling law expert, said at a media briefing Friday. The case’s outcome could have far-reaching effects on an array of political and policy issues, including immigration, drug enforcement and gun control.

As a dispute over federalism, legal experts expected Justice Clarence Thomas, a staunch states’ rights advocate, to side with New Jersey. But the state’s argument appeared to sway others as well.

“[PASPA] leaves in place a state law that the state does not want, so the citizens of the State of New Jersey are bound to obey a law that the state doesn’t want but that the federal government compels the state to have,” Justice Anthony Kennedy said, according to transcripts. “That seems commandeering.”

“Congress could have prohibited sports gambling itself,” Justice Samuel Alito suggested to Paul Clement, another former U.S. solicitor general who is representing the NCAA and major sports leagues.

At one point, according to transcripts, as Justice Stephen Breyer attempted to summarize New Jersey’s arguments, Olson thanked him for doing it better than he could have.

“I wish I had said that myself, Justice Breyer,” Olson said.

The liberal justices, including Justice Elena Kagan and Justice Sonia Sotomayor, were more skeptical, questioning why the federal government’s supremacy over states didn’t pre-empt them when it came to sports wagering, as it does on many other issues. But by the end of the hearing, legal observers believed that New Jersey had a majority of justices on its side.

I see a 6-3 vote in favor of NJ in today’s sports betting case at #SCOTUS. — Daniel Wallach (@WALLACHLEGAL) December 4, 2017

So did the American Gaming Association, which has supported New Jersey’s push to overturn PASPA.

“Today is a positive day for the millions of Americans seeking to legally wager on sporting events,” Geoff Freeman, the organization’s president and CEO, said in a statement. “While we can’t predict the intentions of Supreme Court Justices, we can accurately predict the demise of the Professional and Amateur Sports Protection of 1992.”

The Supreme Court could rule on the case as soon as next spring. And if the court strikes PASPA down in its entirety, many other states could soon follow New Jersey’s lead, as legislatures and governors look to capitalize on potential revenue from a now-illegal sports wagering market the American Gaming Association says is as big as $150 billion per year nationwide.

But even states with little or no interest in legal sports wagering are watching the court’s moves in Christie v. NCAA closely. The anti-commandeering doctrine at question is a product of two decisions, including a 1997 case over the constitutionality of part of the Brady Handgun Violence Prevention Act, in which the court ruled that the government could not compel local law enforcement officials to help federal officials conduct background checks on gun purchases.

Though the doctrine remains controversial, it has helped create room for states to take other actions at odds with federal law and law enforcement, most notably allowing them to decriminalize or legalize medical and recreational use of marijuana even though federal policy has not shifted similarly.

It has become a key issue early in President Donald Trump’s time in the White House as well. In January, Trump issued an executive order to pull federal funding from so-called sanctuary cities — those that place some limits on how they comply with federal immigration authorities, particularly when it comes to undocumented immigrants. After various cities sued the administration, arguing that rescinding federal funds over its status as a sanctuary city was unconstitutional, a federal judge temporarily halted the order in September. Another federal judge later permanently halted the same order.

The Supreme Court could provide officials in sanctuary cities yet another legal boost in their fights over Trump’s immigration crackdowns if it rules in favor of New Jersey’s gambling effort, said Ilya Somin, a George Mason University law professor who has argued that Trump’s order is unconstitutional.

“If New Jersey wins in this case, it is a sign of the Supreme Court’s willingness to take a relatively serious line on commandeering generally,” Somin said. “So even though the arguments are quite different, it would be an indirect good sign [for sanctuary cities].”

Regardless of how the Supreme Court ultimately rules in the New Jersey case, the fight to legalize sports wagering could soon shift back to its original venue: Congress.

Rep. Frank Pallone (D-N.J.) introduced legislation on Monday that would repeal PASPA and give states the authority to regulate gambling within their borders. Pallone has introduced The Gaming Accountability and Modernization Enhancement Act, as the bill is known, in previous years, but the Supreme Court case and the fact that a majority of Americans now support legal sports gambling could provide it new momentum now.

“I am hopeful that the Supreme Court will decide in New Jersey’s favor, and the GAME Act provides the necessary legal framework for states to move forward,” Pallone said in a statement.