NEWARK, N.J. — A federal judge upheld a 21-year-old law prohibiting sports betting in all but four states, dealing a setback to New Jersey’s attempts to revive its struggling casino industry by grabbing a piece of what has become a multibillion-dollar industry, both legal and illegal.

The ruling published late Thursday night marked the second defeat for New Jersey in a lawsuit filed last year by the four major pro sports leagues and the NCAA. In a December ruling, U.S. District Judge Michael Shipp denied the state’s claim that the leagues and NCAA didn’t have standing to bring the suit because they couldn’t demonstrate tangible harm to their products if New Jersey were to allow sports betting.

The state is expected to appeal Thursday’s ruling to the 3rd U.S. Circuit Court of Appeals and, possibly, the U.S. Supreme Court.

State Sen. Ray Lesniak, the prime sponsor of the sports betting bill, said New Jersey would appeal Shipp’s “patent misinterpretation of the Constitution.”

“This is a huge disappointment for all of us who continue to believe that New Jersey should have the right to allow sports betting,” Lesniak said in a statement. “Along with online gaming, sports betting would allow New Jersey to be in the forefront of the modern gaming industry, creating jobs and providing both immediate and long-term economic benefits.”

New Jersey voters passed a sports betting referendum in 2011, and last year the Legislature enacted a sports betting law that limited bets to the Atlantic City casinos and the state’s horse racing tracks. Bets wouldn’t be taken on games involving New Jersey colleges or college games played in the state. Gov. Chris Christie said at the time that he hoped to grant sports betting licenses by early this year, but those plans have been put on hold. Christie’s spokesman didn’t immediately respond to an email seeking comment on the decision Friday.

The NFL, NHL, NBA, Major League Baseball and the NCAA sued the state last year, and the NCAA has moved several of its championship events out of New Jersey because of the sports betting law.

New Jersey, represented by former U.S. Solicitor General Theodore Olson, among others, had attacked the 1992 Professional and Amateur Sports Protection Act, or PASPA, on several constitutional levels. In filings, the state argued the law unfairly “grandfathered” Nevada, Oregon, Montana and Delaware, which already have some form of sports gambling. New Jersey said the law violated state sovereignty and equal protection provisions and trampled the authority of state legislatures under the 10th Amendment.

On Thursday, Shipp said that although some of the questions raised in the case were novel, “judicial intervention is generally unwarranted no matter how unwise a court considers a policy decision of the legislative branch. As such, to the extent the people of New Jersey disagree with PASPA, their remedy is not through passage of a state law or through the judiciary, but through the repeal or amendment of PASPA in Congress.”

In arguments earlier this month, U.S. Attorney Paul Fishman, representing the Justice Department, said the Constitution empowers Congress to regulate an interstate industry such as sports gambling and to treat states differently.

Attorneys for the leagues have said that PASPA doesn’t supersede the authority of state legislatures because it doesn’t require any affirmative actions such as enacting new laws.

New Jersey was given a special dispensation by Congress to approve sports gambling at its casinos within a year in the early `90s, but didn’t do so.

Billions of dollars are bet legally each year on sports in Nevada, and experts estimate tens or even hundreds of billions are wagered illegally through bookmakers.