An advertising agency that helped develop marketing campaigns for OxyContin and other prescription painkillers has agreed to pay U.S. states $350 million rather than face the possibility of trials over its role in the opioid crisis, attorneys general said Thursday.

Publicis Health, part of the Paris-based media conglomerate Publicis Groupe, agreed to pay the entire settlement in the next two months, with most of the money to be used to fight the overdose epidemic.

It is the first advertising company to reach a major settlement over the toll of opioids in the U.S. It faced a lawsuit in at least Massachusetts but settled with most states before they made court claims against it.

The office of New York Attorney General Letitia James, who led negotiations with the company, said Publicis worked with OxyContin maker Purdue Pharma from 2010-2019, helping campaigns for OxyContin and other prescription opioids, Butrans and Hysingla.

James' office said the materials played up the abuse-deterrent properties of OxyContin and promoted increasing patients' doses. While the formulation made it harder to break down the drug for users to get a faster high, it did not make the pills any less addictive.

Washington Attorney General Bob Ferguson said the company provided physicians with digital recorders so Publicis and Purdue could analyze conversations that the prescribers had with patients about taking opioids.

As part of the settlement, Publicis agreed to release internal documents detailing its work for Purdue and other companies that made opioids.

The company did not immediately return a call from The Associated Press.

Drugmakers, wholesalers, pharmacies, at least one consulting company and a health data have agreed to settlements over opioids with U.S. federal, state and local governments totaling more than $50 billion.

One of the largest individual proposed settlements is between state and local governments and Connecticut-based Purdue Pharma. As part of the deal, members of the Sackler family who own the company would contribute up to $6 billion, plus give up ownership. The U.S. Supreme Court is weighing whether it's appropriate to shield family members from civil lawsuits as part of the deal.

The opioid crisis has killed hundreds of thousands of Americans in three waves.

The first began after OxyContin hit the market in 1996 and was linked mostly to prescription opioids, many of them generics. By about 2010, as there were crackdowns on overprescribing and black-market pills, heroin deaths increased dramatically. Most recently, opioids have been linked to more than 80,000 deaths a year, more than ever before. Most involve illicitly produced fentanyl and other potent lab-produced drugs.