Mallinckrodt Pharmaceuticals, the largest generic opioid manufacturer in the United States, has tentatively agreed to pay $1.6 billion to settle thousands of lawsuits brought by state and local governments over its role in the opioid crisis.

The agreement was endorsed by 47 states and U.S. territories along with a committee of lawyers representing thousands of cities and counties, the company said on Tuesday.

The money, to be paid into a cash trust over eight years, will be used to underwrite the costs of opioid addiction treatments and related efforts across the country.

“Nothing can undo the devastating loss and grief inflicted by the opioid epidemic upon victims and their families, but this settlement with Mallinckrodt is an important step in the process of healing our communities,” Attorney General Xavier Becerra of California said in a statement announcing the agreement. “Our office has worked aggressively to hold accountable bad actors who fueled this public health crisis.”