WASHINGTON — The Senate on Tuesday overwhelmingly approved the most substantial changes in a generation to the tough-on-crime prison and sentencing laws that ballooned the federal prison population and created a criminal justice system that many conservatives and liberals view as costly and unfair.

The First Step Act would expand job training and other programming aimed at reducing recidivism rates among federal prisoners. It also expands early-release programs and modifies sentencing laws, including some mandatory minimum sentences, to more equitably punish drug offenders.

But the legislation falls short of bench marks set by a more expansive overhaul proposed in Congress during Barack Obama’s presidency and of the kinds of changes sought by some liberal and conservative activists targeting mass incarceration.

House leaders have pledged to pass the measure this week, and President Donald Trump, whose support resuscitated a yearslong overhaul effort last month, was expected to sign the bill.

Even as both sides acknowledged concessions, Tuesday’s vote was an important first step for the unlikely coalition of liberals and conservatives — including the American Civil Liberties Union, the American Conservative Union, the Koch brothers and the liberal Center for American Progress — who locked arms in recent years and pushed lawmakers to reconsider the way the federal government administers justice three decades after the war on crime peaked.

For Republicans preparing to relinquish total control of Washington next month, the bill’s passage offered one final victory on their own terms and handed Trump a bipartisan policy achievement that he can tout as he seeks re-election. Liberals saw reason to celebrate, as well: In gaining the support of Trump and so many Senate Republicans, they believe they have shifted the terms of policy debates around criminal justice in a way that could set the stage for additional changes on the federal level and in the states.

“This bill in its entirety has been endorsed by the political spectrum of America,” said Sen. Richard J. Durbin, D-Ill., who has led the push for changes. “I can’t remember any bill that has this kind of support, left and right, liberal and conservative, Democrat and Republican.”

Sen. John Cornyn of Texas, the chamber’s No. 2 Republican, who as recently as last week was blocking a Senate vote, stood on the Senate floor Tuesday to make the conservative argument for the changes, which he said would not only achieve fiscal savings but also “human potential.”

“We’re not just talking about money. We’re talking about human potential,” Cornyn said Tuesday. “We’re investing in the men and women who want to turn their lives around once they’re released from prison, and we’re investing in so doing in stronger and more viable communities.”

Proponents of the bill overcame an aggressive campaign by some conservatives who tried to resurrect the once-resonant charge that reducing sentences would make the United States less safe. Two Republicans, Sens. Tom Cotton of Arkansas and John Kennedy of Louisiana, introduced amendments to significantly limit which types of offenders would be eligible for early-release programs and to water down other changes. All were narrowly voted down on the Senate floor Tuesday.

Many of the changes adopted by the Senate and embraced by Trump are modeled after successful initiatives at the state level intended to reduce the costs and improve the outcomes of the criminal justice system. Congress’ action would not directly affect state prisons, where the majority of the country’s offenders are incarcerated, but proponents believe they could spur more states to change their laws.

Once signed into law, thousands of inmates will be eligible for immediate sentencing reductions and expanded early-release programs. Going forward, the effect will grow as thousands of new offenders receive reduced sentences and enter a changed prison system.

Broadly speaking, the First Step Act makes heavy investments in a package of incentives and new programs intended to improve prison conditions and better prepare low-risk prisoners for re-entry into their communities.

By participating in the programs, eligible prisoners can earn time credits to reduce their sentence or enter “pre-release custody,” such as home confinement. In recent weeks, conservative senators and law enforcement groups successfully pushed to limit some violent offenders from eligibility, including fentanyl traffickers.

The legislation would also prohibit the shackling of pregnant inmates and the use of solitary confinement for juveniles in almost all cases. The Bureau of Prisons would be required to place prisoners in facilities close to their homes, if possible.

In all, it includes four changes to federal sentencing laws. One would shorten mandatory minimum sentences for some nonviolent drug offenses, including lowering the mandatory “three strikes” penalty from life in prison to 25 years. Another would provide judges greater liberty to use so-called safety valves to go around mandatory minimums in some cases. The bill would also clarify that the so-called stacking mechanism making it a federal crime to possess a firearm while committing another crime, like a drug offense, should apply only to individuals who have previously been convicted.

Finally, the bill would allow offenders sentenced before a 2010 reduction in the sentencing disparity between crack and powder cocaine to petition for their cases to be re-evaluated. The provision could alter the sentences of several thousand drug offenders serving lengthy sentences for crack-cocaine offenses. That would help many African-American offenders who were disproportionately punished for crack dealing while white drug dealers got off easier for selling powder cocaine.

For the bill’s supporters, Tuesday’s vote was the culmination of a five-year campaign on Capitol Hill that only months ago appeared to be out of reach while Trump was in office.

Much of the same coalition that pushed the First Step Act had rallied around similar legislation, the Sentencing Reform and Corrections Act of 2015. With Obama’s support, as well as that of Sen. Charles E. Grassley, R-Iowa, and House Speaker Paul Ryan, R-Wis., the more expansive bill had appeared destined for passage before Sen. Mitch McConnell, R-Ky., the Senate majority leader, stepped in and refused to give it a vote in the runup to the 2016 election.

McConnell seemed intent on denying proponents another shot this year, but they secured a powerful ally early on in Trump’s son-in-law, Jared Kushner.

Over the course of the past year, Kushner worked with Grassley, Durbin and Sen. Mike Lee, R-Utah, to draft a compromise that the president could back. With Trump’s endorsement, the group brought a strong majority of Senate Republicans on board. By last week, under intense pressure from his own party and the White House, McConnell relented.

For Democrats and Republicans who favored greater changes, Trump’s endorsement came at a cost: They had to scale back their proposed sentencing changes. The 2015 bill made all sentencing reductions retroactive to include those currently in prison, but the bill passed Tuesday limits most of those changes to future offenders.

But by winning the support of a tough-talking, anti-crime president who enjoys deep loyalty among Republican voters, the groups believe they have shifted the debate in a way that could set the stage for additional changes and elevate the criminal justice debate before the 2020 Democratic primaries.