Walgreens Co. is liable for substantially contributing to the opioid epidemic in San Francisco as the city’s largest dispenser of prescription opioids, a California federal judge ruled.

Walgreens stood as the remaining defendant in a bench trial brought by the city and county of San Francisco, alleging manufacturers, distributors and dispensers of prescription opioids created a public nuisance in the city. Ahead of the trial, defendants Teva Pharmaceutical Industries Ltd. and its subsidiary Anda Inc., AbbVie Inc.’s Allergan and Endo Health Solutions reached settlement agreements.