WASHINGTON — The House and Senate have reached agreement on a big package of measures to address the opioid epidemic. The legislation, backed by leaders of both parties, is a rare bipartisan achievement that lawmakers are eager to have in hand when they go home to campaign for the midterm elections.

The 653-page bill contains a mix of law enforcement and public health measures, including one that aims to block deadly fentanyl from being imported through the mail and one that will allow more nurses to prescribe medication for opioid addiction. Another provision could make it easier for Medicaid recipients to get inpatient care for substance abuse over the next five years.

“While there is more work to be done, this bipartisan legislation takes an important step forward and will save lives,” a group of Republican and Democratic committee leaders said in a statement.

But addiction experts say that while many of the measures will help incrementally, the investment remains meager and scattershot compared with what is needed, and with what the government spent to stem the tide of AIDS-related deaths in the 1990s.