A federal judge rejected OxyContin maker Purdue Pharma’s bankruptcy settlement of thousands of lawsuits over the opioid epidemic Thursday because of a provision that would protect members of the Sackler family from facing litigation of their own.

U.S. District Judge Colleen McMahon in New York found that federal bankruptcy law does not give the bankruptcy judge who had accepted the plan the authority to grant that kind of release for people who are not declaring bankruptcy themselves.

In a statement Thursday night, the company said that it would appeal the ruling and at the same time try to forge another plan that its creditors will agree to.

Purdue said the ruling will not hurt the company’s operations, but it will make it harder for company and Sackler money to be used to fight the opioid crisis as the legal fight continues.

“It will delay, and perhaps end, the ability of creditors, communities, and individuals to receive billions in value to abate the opioid crisis,” said Steve Miller, chairman of the Purdue board of directors. “These funds are needed now more than ever as overdose rates hit record-highs, and we are confident that we can successfully appeal this decision and deliver desperately needed funds to the communities and individuals suffering in the midst of this crisis.”

Representatives of the two branches of the family who own the company did not immediately respond to a request for comment.

A spokesman for the descendants of Mortimer Sackler, one of the late brothers who owned the company, had no comment.

Connecticut Attorney General William Tong, who was among a handful of state officials seeking to have the deal undone, called the ruling “a seismic victory for justice and accountability.” Tong said the ruling will “re-open the deeply flawed Purdue bankruptcy and force the Sackler family to confront the pain and devastation they have caused.”

Purdue sought bankruptcy protection in 2019 as it faced thousands of lawsuits claiming the company pushed doctors to prescribe OxyContin, helping spark an opioid crisis that has been linked to more than 500,000 deaths in the U.S. over the last two decades.

Through the bankruptcy court, it worked out a deal with its creditors. Members of the Sackler family would give up ownership of the company, which would transform into a different kind of entity that would still sell opioids — but with profits being used to fight the crisis. It would also develop new anti-addiction and anti-overdose drugs and provide them at little or no cost.

Sackler family members also would contribute $4.5 billion in cash and charitable assets as part of an overall deal that could be worth $10 billion, including the value of the new drugs, if they’re brought to market.