The city is the first municipality in Massachusetts to file such a suit, said Pete Merrigan, of Sweeney Merrigan, the city's law firm. Dozens of states, counties, municipalities and even hospitals across the country have filed similar lawsuits.
The city, home to 18,000 residents, seeks unspecified damages caused by the opioid epidemic, including the costs of providing medical care and treatment for the addicted.
"Let's stop kidding ourselves and have them own up to their obligation to be compliant with the law, which would prevent community addiction," Greenfield Mayor William Martin told The Recorder newspaper.
The city seeks to "eliminate the hazard to public health and safety" caused by the opioid epidemic and recover money spent "because of defendants' false, deceptive and unfair marketing," according to the suit filed in U.S. District Court in Springfield.
One of the nearly two dozen defendants is Connecticut-based Purdue Pharma, the developer of OxyContin.
"We are deeply troubled by the prescription and illicit opioid abuse crisis, and are dedicated to being part of the solution," the company said in a statement. "We vigorously deny these allegations."
Northwestern District Attorney David Sullivan, the prosecutor whose jurisdiction includes Greenfield, endorsed the lawsuit.
"Opioid manufacturers and distributors need to be held accountable for their outrageous sales and marketing practices," Sullivan said in a statement.
The Massachusetts attorney general is part of a multistate coalition investigating whether drug-makers sought to increase profits by misrepresenting the dangers of prescription painkillers and ignoring the public health risks of spiking opioid sales, but a spokeswoman says no lawsuit has been filed.
The city of Quincy indicated in late October that it intended to sue opioid manufacturers, but a spokesman for Mayor Thomas Koch said no suit had been filed as of Friday.
Sweeney Merrigan represents several other Massachusetts cities considering lawsuits, Merrigan said.
This story has been corrected to show the law firm representing Greenfield is Sweeney Merrigan, not Merrigan Sweeney.
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.