Legislation aimed at reducing addiction and deadly overdoses from opioids sailed through its final congressional hurdle on Wednesday, and was headed to President Trump's desk for his signature.

The Senate passed the legislation, called the SUPPORT for Patients and Communities Act, on Wednesday afternoon following months of hearings and negotiations that spread across multiple committees. The bill passed nearly unanimously, with Sen. Mike Lee, R-Utah, the only one to vote against it.

The move represents a bipartisan win both parties can leverage heading into the Nov. 6 midterm elections, since it shows they can work across the aisle to tackle a harrowing public health crisis.

The bill is meant to address several aspects of the opioid crisis — which involves overdose deaths from prescription painkillers and heroin — through medical research, expanding access to treatment, giving more tools to law enforcement, and allocating roughly $8.5 billion in funding authorized in appropriations bills passed earlier this year. The legislation easily cleared the House Friday.

Some Democrats have said they would like to see more money spent on the problem. Sen. Elizabeth Warren, D-Mass., and Rep. Elijah Cummings, D-Md., had introduced measures that would have provided $100 billion toward the effort over a decade, which was modeled after the bill Congress passed to fight the HIV epidemic during the 1990s.

Ahead of the vote, Sen. Lamar Alexander, chairman of the Health, Education, Labor, and Pensions Committee, called the situation "the most urgent public health epidemic facing our country today in virtually every community." He pointed to the appropriations bills amid criticisms about funding and said the opioid crisis needed to be solved by communities, rather than through a "moonshot."

"I wish we could have one ... This problem won't solve itself from here. We can't assign this to an agency and say, 'fix this in 10 years," he said.

The opioid crisis, which resulted in more than 50,000 overdose deaths in 2017, began with the over-prescribing of painkillers by doctors. Patients then became hooked on the drugs, and many turned to heroin, a cheaper alternative. Fentanyl, an even stronger opioid that is more deadly, has caused the vast majority of deaths in recent years and is mixed with drugs, often without the users' knowledge.

The issue has bled into other areas of health and the economy. People who use drugs are unable to pass drug tests to secure jobs, and the spread of HIV and hepatitis C has increased in communities where sharing infected needles is common. Patients with severe pain have said they do not have an alternative allowing them to find relief, and patients who seek treatment for addiction often make several attempts and cycle through the criminal justice system. Drug users report that they have been revived with the drug naloxone during an overdose but then did not receive treatment for addiction, causing them to return to drug use and overdose again at a later time.

In large part because widespread drug use started with doctor prescriptions, lawmakers have approached the issue with a public health focus rather than drug wars of the past that stressed law enforcement.

The legislation passed Wednesday, which spans more than 650 pages, aims to tackle the crisis by going after different angles that have made it more difficult for healthcare workers to respond. It allows hospitals to take in more patients with addiction to receive government funding, allows more medical providers to prescribe addiction treatment, helps the postal service intercept fentanyl from being sent through the mail, and encourages the development of a non-addictive treatment to pain. Lawmakers stressed that they saw the bill as only the beginning.

"I and we will keep fighting," Sen. Shelley Moore Capito, R-W.Va., vowed from the Senate floor.

Sen. Patty Murray, the top Democrat on the HELP Committee, echoed the idea that Congress can't stop working on the problem.

"This is an important bill," the Washington lawmaker said. "It is an impactful step forward. It is not a final step by any means. The opioid crisis is ongoing an our efforts to address it must be as well."

[Opinion: As Senate considers opioid package, here’s one way to help a vulnerable population]