WASHINGTON — After years of negotiations, Congress has passed a sweeping a criminal justice reform bill Thursday that will allow people who committed nonviolent crime to earn shorter sentences.

The House passed the First Step Act 358–36. It had already passed the Senate on Tuesday by a bipartisan vote of 87–12. President Trump, who has endorsed the bill, just needs to sign it into law, which he is expected to do.

It is arguably the most significant piece of criminal justice reform legislation since the 1990s. The bill would grant relief to between 2,000 and 3,000 people still serving jail time under the old system when possession of crack cocaine was treated as 100 times more serious than possession of powdered cocaine. That disparity was greatly reduced in 2010 but was not made retroactive to people already in jail.

The bill allows prisoners deemed “low-risk” to earn early release credits by taking part in anti-recidivism activities such as behavioral courses. It also grants more leeway to judges to sentence nonviolent offenders to prison terms below the mandatory minimums.

The bill also reforms “three strikes” laws by capping the second strike sentence to 15 years of imprisonment, down from 20 years, and the third strike to 25 years, down from a life sentence.

Efforts to craft a justice reform package date back to the first term of the Obama administration. Efforts repeatedly stalled, but gradually picked up steam over the years as a bipartisan group of lawmakers worked their colleagues. In the Obama years, Sen. Chuck Grassley went on the Senate floor to rail against the initiative. He eventually got on board and this year, as chair of the Senate Judiciary Committee, was one of the bill’s most influential champions.

The finish line still seemed far away as early as the beginning of this month, as Senate majority leader refused to bring it forward to a vote. But eventually so many senators signed on board that McConnell moved it forward — and even ended up voting for it himself.

Still, getting to this point was not easy. Proponents of the bill had to make many concessions and the legislation was considerably whittled down. Early release initially would have applied to a much larger share of the criminal population. But many lawmakers feared attacks that they were granting early release to criminals who had committed heinous crimes, and the list of offenses someone could commit and still be eligible for early release shrank considerably.

Much of the bill also was not made retroactive.

“There were a lot of compromises that had to be made along the way,” Utah Sen. Mike Lee, one of the main Republican voices pushing for reform, said earlier this month. “But I feel very good about the bill. If it passes into law it will do a lot of good for our country.”