OxyContin maker Purdue Pharma filed for Chapter 11 bankruptcy protection on Sunday, collapsing under the weight of thousands of lawsuits from states and individuals seeking damages stemming from the opioid crisis.

Purdue's board approved the much-anticipated bankruptcy filing, days after reaching a tentative deal to settle some 2,000 opioid lawsuits filed by local governments, Native American tribes and half the states suing the company over the toll of opioids.

"This settlement framework avoids wasting hundreds of millions of dollars and years on protracted litigation," said Chairman of Purdue's board of directors, Steve Miller, in a statement. He said it "instead will provide billions of dollars and critical resources to communities across the country trying to cope with the opioid crisis."

As part of the deal, Purdue would be restructured into a public benefit trust. The deal will cost the company and its billionaire owners, the Sackler family, about $10 billion, according to Miller. That includes $3 billion from the Sackler family's personal fortune as well as agreeing to sell their Britain-based drug company, Mundipharma.

The Stamford, Connecticut-based company has been accused by nearly every U.S. state of downplaying how dangerously addictive its blockbuster pain killer is while exaggerating its benefits. The Sackler family, which owns Purdue Pharma, has been blamed for helping fuel an opioid epidemic that's claims an average of 130 lives a day. They've also been ostracized from the philanthropy circles they once traveled as museums across the world reject their donations. Prosecutors say the company's marketing practices encouraged doctors to push higher doses of the narcotic and contributed to a public health crisis that has caused thousands of overdoses in the U.S. each year.

The privately held company has previously warned that the cascade of lawsuits, which show no signs of slowing any time soon, put it at risk of bankruptcy.

Purdue and lead plaintiff litigators in the case had been negotiating for months to settle the lawsuits over the opioid crisis to avoid a trial, expected to begin in October. On Sept. 7, the Associated Press reported that Purdue was expected to file for bankruptcy after those talks hit an impasse. The next day, the company said it was still interested in continuing negotiations.

On Sept. 11, Purdue Pharma reached a tentative agreement to settle some 2,000 opioid lawsuits filed by local governments, Native American tribes and states set to go to trial next month. That deal didn't include several states, including Massachusetts, Connecticut and New Jersey.

Opioid drugmaker Insys Therapeutics filed for Chapter 11 bankruptcy protection June 10, marking the first drugmaker driven to bankruptcy due to its legal costs tied to the opioid crisis. Opioid maker Mallinckrodt reached a tentative settlement with two Ohio counties in early September following reports that it might file for bankruptcy.

The attorneys representing Purdue say accusations against the company are "not supported by facts and are fundamentally flawed," adding its opioid painkiller represents less than 2% of the U.S. market. They also say new lawsuits rehash a lot of the same old allegations.

However, court filings against Purdue paint a different picture. Legal documents contend the company over the years repeatedly failed to alert authorities to reports its painkillers were being abused. The Sackler family also boasted about its sales, documents show. According to a court filing in Massachusetts, Richard Sackler, who was the company's president from 1999 to 2003, said at an event that "the launch of OxyContin Tablets will be followed by a blizzard of prescriptions that will bury the competition. The prescription blizzard will be so deep, dense, and white."

In March, Purdue and the Sacklers agreed to pay $270 million to Oklahoma to settle a lawsuit accusing the drugmaker of ruthlessly marketing and misleading the public about OxyContin. As a part of that agreement, Purdue agreed to contribute $102.5 million to fund the creation of a National Center for Addiction Studies at Oklahoma State University.

OxyContin is a prescription drug used to treat moderate-to-severe pain in adults. From 1999 to 2017, nearly 218,000 people died in the United States from overdoses related to prescription opioids, according to the U.S. Centers for Disease Control and Prevention. OxyContin first came on the market in 1996.

— CNBC's Lauren Hirsch contributed to this article.