McKesson Corp, Cardinal Health Inc, AmerisourceBergen Corp and Teva Pharmaceutical Industries Ltd settled with plaintiffs in the counties of Summit and Cuyahoga in Midwestern state of Ohio.
The first three will pay $215 million immediately while Teva Pharmaceutical will pay $20 million. Teva will also be donating $25 million worth of Suboxone
The case was dismissed with prejudice by US District Court Judge Dan Polster.
This was the first federal multidistrict litigation (MDL) trial involving the opioid epidemic. Thousands of similar plaintiffs' cases are awaiting trial.
MDL is similar to class-action in that plaintiffs' pretrial proceedings are consolidated for more efficiency.
However, each plaintiff can get a different verdict or award. Summit and Cuyahoga counties are the first among more than 2,700 plaintiff communities to go to trial.
AmerisourceBergen, Cardinal Health and McKesson issued a joint statement saying the settlement does not mean they are at fault.
"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," the joint statement said.
"The companies expect settlement funds to be used in support of initiatives to combat the opioid epidemic, including treatment, rehabilitation, mental health and other important efforts.
"The distributors remain deeply concerned about the impact the opioid epidemic is having on families and communities across the nation - and are committed to being part of the solution."
The money will go towards treatment for opioid addiction, which has swept the US and led to mass overdoses.
Attorneys general from North Carolina, Tennessee, Pennsylvania and Texas said the settlement is "an important step" in combating the opioid epidemic.
"People in every corner of the country have been hurt by this crisis, and it is critical that settlement funds be distributed fairly across states, cities, and counties and used wisely to combat the crisis," the attorneys general said.
"The global resolution we are working to finalize will accomplish those goals while also ensuring that these companies change their business practices to prevent a public health crisis like this from ever happening again."