(Reuters) - A Manhattan federal judge on Wednesday blocked New York state from enforcing a recently enacted law that aimed to collect $600 million from drug manufacturers and distributors to defray the costs of combating the opioid addiction epidemic.

U.S. District Judge Katherine Polk Failla ruled that while the concerns driving New York’s decision to adopt the law were valid, the means by which the state would extract payments from the companies violated the U.S. Constitution.

The ruling came in a trio of lawsuits by drug wholesale distributor group Healthcare Distribution Alliance (HDA); the Association for Accessible Medicines, a generic drug manufacturers group; and Mallinckrodt Plc unit SpecGx.

Failla said the law’s prohibition on companies passing on to consumers the costs of making the payments to the state of New York violated the Constitution’s “dormant” Commerce Clause, which bars states from regulating interstate commerce.

She said the law improperly regulated the companies’ relationships with out-of-state consumers by barring drugmakers from passing on the costs to them and threatening significant penalties for doing so.

“New York nowhere concedes that it will never charge the penalty for out-of-state sales, only that it has displayed no current intention to do so,” Failla wrote.

Representatives for the groups behind the lawsuits welcomed the ruling. HDA in a statement called the surcharge the “wrong way to address the opioid epidemic.”

The New York State Department of Health said it was considering its options.

Democratic Governor Andrew Cuomo signed the Opioid Stewardship Act into law in April.

Its passage marked a novel instance of a state seeking to tax opioid manufacturers and distributors to combat the drug epidemic. Other states have considered similar proposals.

According to the U.S. Centers for Disease Control and Prevention, opioids were involved in over 49,000 overdose deaths nationwide in 2017.

The law created a fund to finance addiction treatment programs bankrolled entirely by manufacturers and distributors of prescription painkillers in New York.

The companies would collectively pay $100 million annually into the fund from 2019 to 2024. The exact amount a company owed would be based on its share of annual opioid sales.

The first payments were due on Jan. 1 and were calculated based on 2017 sales. Mallinckrodt’s SpecGX, a generic drugmaker, said in court papers it owed $1.2 million.

Drug distributor AmerisourceBergen Corp estimated in November it would owe $22 million for its share from 2017 through September 2018.