After two years of wrangling, the country’s three major drug distributors and a pharmaceutical giant have reached a $26 billion deal with states that would release some of the biggest companies in the industry from all legal liability in the opioid epidemic, a decades-long public health crisis that has killed hundreds of thousands of Americans.

The announcement was made Wednesday afternoon by a bipartisan group of state attorneys general.

The offer will now go out to every state and municipality in the country for approval. If enough of them formally sign on to it, billions of dollars from the companies could begin to be released to help communities pay for addiction treatment and prevention services and other steep financial costs of the epidemic.

In return, the states and cities would drop thousands of lawsuits against the companies and pledge not to bring any future action.

The settlement binds only these four companies — the drug distributors Cardinal Health, AmerisourceBergen, McKesson, and Johnson & Johnson — leaving thousands of other lawsuits against many other pharmaceutical defendants, including manufacturers and drugstore chains, in the mammoth nationwide litigation still unresolved.

But these four companies are widely seen as among the defendants with the deepest pockets.

In an emailed statement, Michael Ullmann, executive vice president and general counsel of Johnson & Johnson, said: “We recognize the opioid crisis is a tremendously complex public health issue, and we have deep sympathy for everyone affected. This settlement will directly support state and local efforts to make meaningful progress in addressing the opioid crisis in the United States.”

In a joint statement, the three distributors said: “While the companies strongly dispute the allegations made in these lawsuits, they believe the proposed settlement agreement and settlement process it establishes are important steps toward achieving broad resolution of governmental opioid claims and delivering meaningful relief to communities across the United States.”

The distributors, which by law are supposed to monitor quantities of prescription drug shipments, have been accused of turning a blind eye for two decades while pharmacies across the country ordered millions of pills for their communities. Plaintiffs also allege that Johnson & Johnson, which used to contract with poppy growers in Tasmania to supply opioid materials to manufacturers and made its own fentanyl patches for pain patients, downplayed addictive properties to doctors as well as patients.

According to federal data, from 1999 to 2019, 500,000 people died from overdoses to prescription and street opioids. Overdose deaths from opioids hit a record high in 2020, the Centers for Disease Control and Prevention said earlier this month.

Under the agreement, the country’s three distributors would make payments over 18 years. Johnson & Johnson would pay $5 billion over nine years. A key feature of the agreement is that the distributors would establish an independent clearinghouse to track and report one another’s shipments, a new and unusual mechanism intended to make data transparent and send up red flags immediately when outsized orders are made.

A separate deal between the companies and Native American tribes is still being negotiated.

The agreement was presented by attorneys general from North Carolina, Pennsylvania, New York, Delaware, Louisiana, Tennessee and Connecticut.

Wednesday’s announcement suggests that a critical element — a large majority of states agreeing in principle — has been met. But there are daunting obstacles remaining before any checks are actually cut.

The states and the District of Columbia will now have 30 days to closely review the agreement, including how much each would be paid over 17 years. Many states have not yet had the chance to scrutinize the deal. And while many permit their attorneys general to sign off, others require that legislators must be consulted. An unspecified number of states must sign on, for the deal to proceed. If that threshold is not met, the companies could walk away.

While the states are deciding, a trial brought by several California counties in state court against Johnson & Johnson and a local West Virginia trial in federal court against the distributors will continue.

States also have to begin cajoling their localities, including those that have already filed cases and those that have not, to agree to the deal. The greater the number of local governments that sign on, the greater the amount of money each state will receive.

“The lawyers will do a lot of the strong-arming of their clients, the localities, into agreeing to the settlements, because if the deal doesn’t go through, the lawyers won’t get paid,” said Elizabeth Burch, a law professor at the University of Georgia who has followed the litigation closely.