Four drugs companies have reached a $260m (£200m) deal with two Ohio counties over their role in fuelling the US opioid crisis.
The agreement averts a trial that had been scheduled to start in Cleveland.
The counties had been seeking billions from Israel-based drugmaker Teva and drug distributors AmerisourceBergen, Cardinal Health and McKesson.
A trial for Walgreens Boots Alliance, which had also been accused, will be rescheduled.
The last-minute deal was announced on Monday by the judge overseeing the trial in Cleveland.
Talks over a bigger settlement, which would have resolved claims brought by thousands of other cities, counties and states, had collapsed on Friday.
The companies, which have denied wrongdoing, are accused of ignoring suspicious orders and downplaying the risks of opioid painkillers, which have been linked to about 400,000 overdose deaths in the US between 1997 and 2017.
In Monday's deal, they did not admit guilt. But McKesson Corp, Cardinal Health and AmerisourceBergen Corp agreed to pay $215m, while Teva is paying $20m and will contribute $25m worth of treatment medication.
Later on Monday, Teva also said it had reached an "agreement in principle" for a global settlement, which would see it pay $250m and donate treatment medication worth an estimated $23bn over 10 years.
The case involving Ohio's Summit and Cuyahoga counties had been closely watched as the first of thousands of similar ones to go forward.
The two jurisdictions have already struck deals worth more than $66m with firms that include Johnson & Johnson, Purdue Pharma and Allergan.
Cuyahoga County Executive Armond Budish called Monday's deal "a very good development" that will provide money for recovery programmes and other assistance.
"This settlement helps us address the mitigation of the terrible damage that's been caused," he said. "There's still more to go. And we're going to continue to work on it."
The opioid crisis cost the US more than $630bn from 2015 through 2018 in healthcare and policing expense, lost income and other costs, according to recent estimates by the US Society of Actuaries.