CONCORD, N.H. — New Hampshire’s hospitals have agreed to spend $50 million over the next five years to fund the programs that combat the state’s ongoing opioid crisis.

The announcement Friday by Republican Gov. Chris Sununu helps address a long-running debate over how the state would fund drug treatment and prevention programs. Until now, funding for the programs came from a share of the profits from liquor sales. But the state wants to use that money to help fund Medicaid costs as federal funding decreases, which some feared could put treatment funding at risk.

“This is a great example for planning for the long term, thinking creatively, and simply not accepting the way we used to do it,” Sununu said of the partnership with the New Hampshire Hospital Association. “Our partners in the health care industry have stepped forward to support the health of the citizens of New Hampshire by making a substantial investment into addressing the substance use disorder crisis.

Joseph Pepe, the president and CEO of Catholic Medical Center, said the move makes sense considering hospitals like theirs are on the front lines of the opioid crisis.

Opioids, including prescription opioids, heroin and synthetic drugs such as fentanyl, killed more than 42,000 people in the U.S. in 2016, more than any other year on record, according to the Centers for Disease Control and Prevention. New Hampshire has been among the hardest hit states, ranking third in the nation in drug overdoses.

“We serve some of the most of the financially and medically challenged populations in the state. We see it all,” Pepe said. “We understand how essential it is to invest in programs to address substance use disorder … No one hospital, no one treatment or recovering organization, no one legislative effort can end the opioid crisis. But by working together like we are today, we can make a life-saving difference.”

The announcement should also bolster efforts to expand New Hampshire’s Medicaid program, which won initial approval Thursday in the House.

The current program uses Medicaid funds to buy private health plans for about 50,000 low-income residents through the marketplace created under the federal Affordable Care Act, but it will expire this year if lawmakers don’t reauthorize it. The House voted 222-125 to send a reauthorization bill to its finance committee, where members already have been drafting amendments.

As passed by the Senate last month, the bill would continue the program for five years but change its structure to a managed care model. The plan also would impose new work requirements on enrollees and use 5 percent of liquor revenues to cover the state’s cost as federal funding decreases. The version given preliminary approval by the House on Thursday would allow self-employment and seasonal work to satisfy the work requirement.

Sununu said he is also hopeful the new funding could compliment forthcoming federal monies to help finance everything from prevention programs in schools, to rural treatment programs to a new initiative helping recovering substance abusers get jobs. In the $1.3 trillion federal budget appropriation, $142 million will be set aside for the states like New Hampshire.

“Bring us your proposal. Bring us your ideas,” Sununu said. “It doesn’t mean this is a never ending fountain of money and we can do everything we want. We still focus on our priorities straight, focus on the needs of New Hampshire.”