Johnson and Johnson has agreed a $230m settlement with the state of New York to resolve claims it helped fuel the prescription painkiller epidemic.

The company, which made a fentanyl patch and a pill, denied any wrongdoing but said it would “provide New York . . . with up to $263m in funding to address opioid related issues, as well as reimbursement for attorney fees and costs”.

The settlement is a part of a wave of more than 3,000 lawsuits across the US aimed at forcing opioid producers and distributors to take financial responsibility for an epidemic that officials blame on their aggressive marketing of the highly addictive drugs.

The Centers for Disease Control and Prevention estimates that opioid overdoses have killed 500,000 Americans over two decades. Many of those deaths involved prescription painkillers made by drugmakers and prescribed by doctors.

By settling, J&J will avoid going on trial next week, when New York state is scheduled to face other opioid makers and distributors in court.

“The opioid epidemic has wreaked havoc on countless communities across New York state and the rest of the nation, leaving millions still addicted to dangerous and deadly opioids,” New York Attorney General Letitia James said in a statement.

“Johnson & Johnson helped fuel this fire, but today they’re committing to leaving the opioid business — not only in New York, but across the entire country,” she said.

James added that the pharmaceutical company’s heavy marketing of opioids was partially motivated by quotas for sales staff.

J&J said its “actions relating to the marketing and promotion of important prescription pain medications were appropriate and responsible”. It added that it had already decided to” discontinue all of its prescription pain medications” last year.

In March 2019, James filed a sprawling lawsuit against opioid manufacturers and distributors. In addition to J&J, the complaint named Purdue Pharma and the members of the Sackler family that own it, Mallinckrodt, Endo, and Teva among others. It also targeted distributors including McKesson, Cardinal Health and Amerisource Bergen.

The cases against Purdue Pharma and the Sackler family and Mallinckrodt are now moving through US Bankruptcy Court. The trial against all the other defendants is scheduled to begin next week.

In August, J&J was ordered by a judge in Oklahoma to pay $465m after it was found responsible at a 2019 trial for the public nuisance of the opioid crisis in the state.