A California judge on Monday said he would rule against several large counties that accused four drugmakers of fueling the U.S. opioid epidemic, saying they failed during a trial to prove their $50 billion case.

Orange County Superior Court Judge Peter Wilson issued a tentative ruling finding Johnson & Johnson, Teva Pharmaceutical Industries Ltd, Endo International PLC and AbbVie Inc’s Allergan unit not liable.

It marked the first trial win for any drug companies in the more than 3,300 lawsuits filed by states and local governments over a drug abuse crisis that the U.S. government says led to nearly 500,000 opioid overdose deaths over two decades.

The ruling came as J&J and the three largest U.S. drug distributors – McKesson Corp, Cardinal Health Inc and AmersourceBergen — work to finalize a proposed deal to pay up to $26 billion to settle the thousands of cases against them.

A bankruptcy judge in August approved a settlement by OxyContin maker Purdue Pharma and its wealthy Sackler family owners of the claims against them that the company values at more than $10 billion.

During a months-long, non-jury trial, the populous Santa Clara, Los Angeles and Orange counties and the city of Oakland argued the drugmakers’ marketing downplayed opioids’ addictive risks and promoted them for broader uses than intended.

They argued the advertising led to billions of pain pills flooding their communities and a rise in overdose deaths. They said the companies should pay more than $50 billion to cover the costs of abating the public nuisance they created, plus penalties.

But Wilson said even if the drugmakers’ marketing contained any misleading statements, the counties put forward no evidence to show that their promotional activities caused any medically inappropriate prescriptions to be written.

He agreed with the companies that the epidemic could not be considered a legal public nuisance because the federal government and the state had at the time determined the benefits of medically appropriate prescriptions outweighed their harms.

“There is simply no evidence to show that the rise in prescriptions was not the result of the medically appropriate provision of pain medications to patients in need,” Wilson wrote.

J&J in a statement said the decision showed its marketing was “appropriate and responsible.” John Hueston, Endo’s lawyer, said it demonstrated his client’s “lawful conduct did not cause the widespread public nuisance at issue in plaintiffs’ complaint.”

Teva in a statement said it continues to pursue a national settlement framework and that the ruling was a “clear win” for patients who would benefit from comprehensive settlements being finalized.

Representatives for the California plaintiffs did not respond to requests for comment. They could potentially challenge the tentative ruling before it becomes final. Tentative decisions are typical in California state courts.

In a statement, the lead lawyers overseeing related federal lawsuits against the companies — Jayne Conroy, Paul Farrell and Joe Rice — said they strongly disagreed with the ruling and stressed that it did not impact related cases nationally.

The only other opioid trial to reach a verdict resulted in an Oklahoma judge in 2019 ordering J&J to pay $465 million to the state. J&J is appealing that decision.

Trials are currently underway a New York case against Teva and AbbVie and in Ohio against three pharmacy chain operators. A West Virginia federal judge recently finished hearing evidence in a trial involving the distributors.