Gov. Tim Walz signed into law Wednesday a plan to increase fees on prescription drug manufacturers and distributors to pay for a statewide response to the opioid epidemic in Minnesota.

The legislation, which passed both chambers with bipartisan support, is expected to raise more than $20 million a year for addiction prevention and treatment to stem the opioid crisis.

“The opioid epidemic is devastating communities across Minnesota — claiming lives and leaving heartbroken families in its wake,” Walz said in a statement. “This law will help more families access the treatment they need and prevent addiction in the first place.”

Under the new law, annual licensing fees drug companies pay to do business in the state will jump from about $200 to up to $305,000 a year. Those fees will drop to $5,000 after five years if the fund reaches $250 million, either through the fees or by a settlement from pending lawsuits against the drug manufacturers.

A 19-member advisory council will use the new funds to issue grants for programs that combat opioid addiction and prevent overdose deaths. The revenue also will pay for law enforcement efforts, programs aimed at providing nonnarcotic pain treatment plans, and county-level services for children whose parents are addicted to drugs.

The bill faced opposition from pharmaceutical companies and some patients.

“Unfortunately, what’s being proposed — taxing legitimately prescribed medicines that patients rely on for legitimate medical needs to raise revenue for the state — ignores evidence-based solutions, sets a dangerous precedent and ultimately won’t help patients and families,” Nick McGee, director of public affairs for the industry trade group PhRMA, told the Star Tribune earlier this year.

That opposition was enough to derail similar proposals in recent years. But supporters said a growing recognition of the scope and seriousness of opioid addiction, as well as the role manufacturers of addictive prescription drugs played in starting the crisis, changed the political dynamic this year.

A record 422 Minnesotans died of opioid overdose deaths in 2017.