WASHINGTON — The Senate on Wednesday approved a bill to tackle the nation’s opioid crisis, sending to the president’s desk the most sweeping drug legislation in years in a rare instance of consensus in Congress.

The measure, which passed, 92 to 2, would strengthen prevention, treatment and recovery efforts, largely by empowering medical professionals and law enforcement officials with more tools to help drug addicts. It would also expand access to a drug that emergency medical workers could use to help reverse overdoses and improve treatment for the incarcerated. Senator Ben Sasse, Republican of Nebraska, and Senator Mike Lee, Republican of Utah, voted against the measure. President Obama is expected to sign the bill.

“This is a historic moment, the first time in decades that Congress has passed comprehensive addiction legislation, and the first time Congress has ever supported long-term addiction recovery,” said Senator Rob Portman, Republican of Ohio, whose state has been plagued by opioid addiction. “This is also the first time that we’ve treated addiction like the disease that it is, which will help put an end to the stigma that has surrounded addiction for too long.”

Tensions over spending threatened to derail the measure as Democrats insisted the Senate also vote on immediate funding to pay for the programs the bill authorizes. Republicans said funding would be addressed in the appropriations process later this year.