The US Senate has passed a sweeping criminal justice reform bill seeking to address concerns that the US locks up too many of its citizens.
The First Step Act, which has been championed by US President Donald Trump, passed by a vote of 87-12.
The bipartisan measure found unlikely support from hardline conservatives and progressive liberals alike.
The US leads the world in number of jailed citizens. Around 2.2m Americans were in jail in 2016, figures show.
The bill, which is expected to be debated in the House of Representatives on Wednesday, would only affect federal prisoners accounting for about 10% of the total US prison population.
Moments after the vote passed, President Trump tweeted: "America is the greatest Country in the world and my job is to fight for ALL citizens, even those who have made mistakes."
What does the law actually do?
The bill would overhaul the US justice system by giving more discretion to judges during sentencing, and by strengthening prisoner rehabilitation efforts.
Among the sentencing guidelines being revised is one reducing the "three strikes" penalty for drug felons from life in prison to 25 years.
The "three strikes" policy - introduced during the Clinton presidency - mandated strict penalties for those convicted of three serious crimes.
The First Step Act also limits the disparity in sentencing guidelines between powder and crack cocaine, which could affect up to 2,600 prisoners, according to the Marshall Project.
It allows for more criminals to serve their sentences in halfway houses or under home confinement, and requires offenders to be jailed within 500 miles (800km) of their families.
It bans shackling pregnant prisoners and mandates that tampons and sanitary napkins be available to women.
It reduces the mandatory minimum sentences for serious drug crimes, and authorises $375m (£297m) in federal spending for job training and educational programmes for prisoners.
New Jersey Democratic Cory Booker hailed the legislation as "one small step [that] will affect thousands and thousands of lives".
How did it get this far?
All 49 Democrats in the Senate voted in favour of the bill, with several mentioning that prisons are disproportionally filled with minority groups.
Twelve conservative law-and-order Republican senators voted against the bill.
Many of the supporters of the First Step Act had also rallied behind the Sentencing Reform and Corrections Act of 2015, which was supported by former President Barack Obama.
That bill looked set for passage before Republican Senate Leader Mitch McConnell blocked it, and refused to put it to a vote in the run-up to the 2016 election.
Earlier this year, White House adviser Jared Kushner began working with Republicans to draft a bill that Mr Trump could sign into law.
With Mr Trump's endorsement, the Republican group was able to shore up enough support to bring the bill to a vote.
"This is the biggest thing," said Republican Senate Judiciary Chairman Chuck Grassley after the vote was held.
So Congress actually did something?
The first two years of the Donald Trump presidency have been defined in part by high-profile partisan battles in Congress - over healthcare, immigration, tax reform and presidential nominees. Beneath the surface, however, there's been a somewhat surprising undercurrent of bipartisan co-operation.
Democrats and Republicans have come together to pass legislation to address the opioid addiction crisis, modernise the Federal Aviation Administration, provide additional resources for veterans and fund vast swaths of the federal government using traditional appropriations processes.
In the last few weeks alone, Congress enacted - and the president signed - a law to provide research and treatment for sickle cell disease, an inherited blood disorder that predominantly affects African-Americans. It unanimously passed a $60m bill to prevent maternal mortality.
This criminal justice reform bill could represent the highest-profile accomplishment yet.
With Democrats in control of the House of Representatives next year, Congress and the president will have no choice but to seek bipartisan solutions if they want to enact any significant legislation. That may be a challenge, given that even as White House press secretary Sarah Huckabee Sanders heralded the reform bill as a "historic win", she couldn't resist taking a shot across the political aisle.
"Imagine how much more we can accomplish in the years ahead if - like on criminal justice - Democrats spend more time working with GOP to build America up and less time tearing the President down," she tweeted.