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, along with drugmaker Teva Pharmaceuticals, the Israeli-based manufacturer of generic opioids. The agreement does not include a fifth defendant, Walgreens, the retail drugstore chain that was sued over its distribution operation. Walgreens’ case has been postponed.

A sixth defendant, Melville, N.Y.-based Henry Schein Medical, announced Monday morning that it had reached a deal worth $1.25 million with the two counties.

Details of the agreement, first reported by The Wall Street Journal, were set to be announced later Monday morning.

In a statement from the bench Monday morning, U.S. District Court Judge Dan Aaron Polster said broader talks to settle all the cases were continuing. Polster, who has urged such a settlement for nearly two years, said the two-county deal announced Monday was reached sometime between midnight and 1 a.m.

Going to trial could have cost the four 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 the condition of anonymity because of the sensitivity of the negotiations. Teva also would supply another $25 million in anti-addiction medication.

“This is a landmark, significant settlement in the history of the opioid epidemic. We were able to make a significant impact in the communities of Cuyahoga and Summit counties. There are no political victories in this. We either make a difference or we don’t,” said Paul T. Farrell Jr, the co-lead plaintiffs counsel.

The settlement follows the collapse of an extraordinary effort Friday to reach a deal covering all the cases. 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 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 rested mainly on the sheer volume of drugs the companies poured into northeastern Ohio. They contended 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 argued that deluge created a “public nuisance” that endangered residents’ health and are seeking $7.2 billion to remedy the crisis. They also sought 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 claimed the companies worked together like a drug cartel, conspiring to expand their market, deceptively promote their products and minimize addiction risks.

The drug companies denied 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 denied working in concert, contending the counties cannot prove any direct link between their conduct and the harms or expenses incurred.