Purdue Pharma, the company that made billions selling the prescription painkiller OxyContin, filed for bankruptcy Sunday night. The move came days after Purdue reached a tentative settlement with many state and local governments of a landmark lawsuit over the toll the opioid epidemic has taken on communities nationwide.

The filing was anticipated before and after the tentative deal, and was part of it. The deal could be worth up to $12 billion over time.

Purdue's board of directors met Sunday evening to approve the filing, the Reuters news service noted. It was made in a federal bankruptcy court in White Plains, New York.

Get Breaking News Delivered to Your Inbox

"This settlement framework avoids wasting hundreds of millions of dollars and years on protracted litigation," Steve Miller, the board's chairman, said in a statement, "and instead will provide billions of dollars and critical resources to communities across the country trying to cope with the opioid crisis. We will continue to work with state attorneys general and other plaintiff representatives to finalize and implement this agreement as quickly as possible."

But legal battles still lie ahead for Stamford, Connecticut-based Purdue, which is spending millions on legal costs as it defends itself in suits from 2,600 government and other entities.

About half the states haven't signed onto the proposed settlement. And several of them plan to object to it in bankruptcy court and to continue litigation in other courts against members of the Sackler family, which owns the company. The family agreed to pay at least $3 billion in the settlement plus contribute the company itself, which is to be reformed with its future profits going to the company's creditors.

In a statement, the families of late company owners Mortimer and Raymond Sackler said they have "deep compassion for the victims of the opioid crisis" and believe the settlement framework "is an historic step toward providing critical resources that address a tragic public health situation."

Objections came over the amount of the deal, which some officials say won't come close to reaching the $12 billion mark, and because it means the company won't be found liable by a jury or judge.

Miller said the company hasn't admitted wrongdoing and doesn't intend to. "The alternative is to not settle but instead to resume the litigation," he said on a conference call with reporters. "The resumption of litigation would rapidly diminish all the resources of the company and would be lose-lose-lose all the way around. Whatever people might wish for is not on the table now."

Because so many states balked at the settlement, it could complicate the bankruptcy process. The Sackler family members said they're still trying to get more states to sign on.

"We are hopeful that in time, those parties who are not yet supportive will ultimately shift their focus to the critical resources that the settlement provides to people and problems that need them," they said.

Key issues that could be decided include whether the suits against the Sacklers in state courts will be able to move ahead, and what will happen to the company itself. One option could be for a judge to order that it be sold.

Court filings assert that members of the Sackler family were paid more than $4 billion by Purdue from 2007 to 2018.

Much of the family's fortune is believed to be held outside the U.S., which could complicate lawsuits against the family over opioids.

A court filing by the New York Attorney General's office on Friday contended that Sackler family members used Swiss and other hidden accounts to transfer $1 billion to themselves. The discovery of the transfers bolsters several states' claims that family members worked to shield its wealth because of the growing legal threats against them and Purdue.

"The controversial piece is going to be about how much the Sacklers need to kick in for the deal to work,'' Adam J. Levitin, a professor specializing in bankruptcy at Georgetown Law, told The Washington Post.

"The Sacklers are going to be left with plenty of money after this,'' he added. "There is a desire that the Sacklers pay some blood money, but it's never going to be enough to make everyone happy.''

The Sacklers have given money to cultural institutions around the world, including the Smithsonian Institution, New York City's Metropolitan Museum of Art and London's Tate Modern.