CLEVELAND (CN) – Striking an 11th-hour deal to avoid a highly anticipated bellwether trial over the nationwide opioid epidemic, three drug distributors and one manufacturer reached a $260 million settlement Monday with two Ohio counties.

Distributors AmeriSource Bergen Corp., Cardinal Health Inc. and McKesson Corp. will pay $215 million of the settlement total, while Israel-based drugmaker Teva will pay $20 million in cash over the next two years. It will also contribute $25 million for addiction-treatment medication.

The trial in Cleveland was set to test Summit and Cuyahoga counties’ nuisance claims against the drug manufacturers and distributors. They are just two of more than 2,000 cases that U.S. District Judge Dan Polster is overseeing brought by cities, counties and tribes across the country.

The settlement only ends the lawsuits brought by those two Ohio counties.

Distributor Henry Schein also announced a separate settlement with Summit County, which includes $1 million to establish a pain management education foundation, leaving pharmacy giant Walgreens as the sole remaining defendant.

Walgreens will now join another set of pharmacy defendants, which include Walmart, CVS, Rite Aid and Discount Drug Mart, for a trial could take place in the first quarter of next year.

Polster, a Bill Clinton appointee, said in his courtroom Monday morning that the deal was struck between midnight and 1 a.m. Eastern time. He said he would retain jurisdiction “to make sure the settlement agreement is reached.”

“This would have been a very interesting case to preside over,” the judge said. “We have the best lawyers in the country, and they would have done a great job presenting the facts and putting those facts into competing narratives.”

“I’m confident that both Summit and Cuyahoga County will use these settlement funds to address and remediate the opioid crisis,” he added.

Outside the courthouse, representatives for the plaintiffs talked about what will happen next.

“This isn’t the end of the trial,” Summit County Executive Ilene Shapiro said. “We still have a lot more to do.”

Cuyahoga County Prosecutor Michael O’Malley said the settlement money will be used “to get people into treatment and to assist first responders.”

“We also want Washington to pass laws to prevent this from happening again,” he added.

Cuyahoga County Executive Armond Budish said the agreement “doesn’t solve the opioid problem,” but the funds will go “to the people who need it.”

Joseph Rice, one of the plaintiffs’ attorneys, said attorney fees will be kept in escrow, and he believes they will eventually be paid by the defendants.

He noted that while Cuyahoga and Summit counties have settled their claims, more than 2,000 other municipalities are still waiting for their day in court.

“This is not a global settlement. There still needs to be one,” Rice said.

Rice was also involved in tobacco litigation, but he said the opioid case is different.

“We knew tobacco would continue to be sold, so we were able to link the settlement funds to future sales,” he said. “We don’t want these drugs to be sold.”

Hunter Shkolnik, another of the plaintiffs’ attorneys, talked about next year’s planned trial, which will focus on the dispensing practices of pharmacies.

“They knew who were the addicts filling their prescriptions,” he said. “We are going to ask, ‘Why didn’t your pharmacists do the right thing?’”

Shkolnik also talked about a proposed $48 billion national settlement that was the subject of recent negotiations, which included attorneys general from four states.

“The billions would have come in trickles, so we had to say no to the national settlement,” he said.

AmeriSource Bergen, McKesson and Cardinal Health said in a joint statement that they are “deeply concerned about the impact the opioid epidemic is having” and “are committed to being part of the solution.”

“While the companies strongly dispute the allegations made by the two counties, they believe settling the bellwether trial is an important stepping stone to achieving a global resolution and delivering meaningful relief,” they said.

Cuyahoga and Summit counties had brought conspiracy, public nuisance and racketeering claims against nearly two dozen defendants, seeking to hold them accountable for the opioid epidemic that has claimed nearly 400,000 lives over the last 20 years.

Brian Grosh contributed to this report.