CLEVELAND — Two Ohio counties settled with four drug companies on the eve of a landmark federal trial over responsibility for the opioid epidemic, in a $260 million deal that emerged just an hour before opening arguments were set to begin Monday.

The deal is with the "Big Three" distributors McKesson Corp., AmerisourceBergen and Cardinal Health and Teva Pharmaceuticals, the Israeli-based manufacturer of generic opioids. It does not include the fifth defendant, Walgreens, the retail drug store chain that was sued over its own distribution operation. It was not clear whether a trial would proceed with Walgreens as the only defendant. A sixth defendant, Henry Schein Medical, announced Monday morning that it had reached a deal worth $1.25 million with the two counties.

Details of the agreement were set to be announced later Monday morning. Late last night, the companies were still negotiating.

Going to trial could have cost the drug companies more than $8 billion if Cuyahoga and Summit counties were awarded all the money they were seeking. It also buys the companies time to try to fashion a more wide-ranging settlement with the 2,400 cities, counties, Native American tribes and others that have sued the drug industry. Their cases have been consolidated in a sprawling "multidistrict litigation" before a federal judge here.

The Ohio counties would receive $215 million in cash from the distributors and another $20 million from Teva, according to people aware of the settlement, who spoke on condition of anonymity because of the sensitivity of the negotiations. Teva also would supply another $25 million in anti-addiction medication.

The settlement with the four companies follows the collapse of an extraordinary effort Friday to reach a deal coveringall the cases. U.S. District Court Judge Dan Aaron Polster summoned the chief executives of the three big distributors and representatives of the other two companies to his courtroom here in an effort to hammer out an agreement.

Also called were the plaintiffs lawyers and four state attorneys general who represented dozens of states that have been negotiating with the drug companies. Nearly every state has sued a variety of companies in state courts.

Polster, who has urged a mass settlement for nearly two years, shuttled among the parties, trying to find common ground. But after about 10 hours of talks, the negotiations ended without agreement.

More than 200,000 people have died of overdoses of prescription narcotics in the past two decades and another 200,000 have succumbed to overdoses of heroin and illegal fentanyl, which is now the main drug propelling the crisis.

The counties' argument rests mainly on the sheer volume of drugs the companies poured into northeastern Ohio. They contend the distributors, motivated by profits, did little to monitor doses that spilled into the black market, ignoring obvious signs as they filled order after order.

They argue that deluge created a "public nuisance" that endangered residents' health and are seeking $7.2 billion to remedy the crisis. They also want another billion in damages.

Polster has ruled that if the jury finds the companies liable, he will decide how much they must pay to remedy the public nuisance.

In August, an Oklahoma judge found health care giant Johnson & Johnson liable for fueling the opioid crisis and order the company to pay the state $572 million on a similar public nuisance claim. After a seven-week trial, Judge Thad Balkman agreed with the state's claim that the company had endangered public health by aggressively marketing opioids and by importing and processing the raw materials for oxycodone.

Johnson & Johnson has appealed that decision.

In this case, Cuyahoga and Summit counties also claim the companies worked together like a drug cartel, conspiring to expand their market, deceptively promote their products and minimize addiction risks.

The drug companies deny the accusations, asserting they delivered legitimate medications to patients suffering from cancer and other painful conditions and complied with regulations set by the DEA and the Food and Drug Administration. They also deny working in concert, contending the counties cannot prove any direct link between their conduct and the harms or expenses incurred.