The House approved the most far-reaching overhaul of the criminal justice system in a generation on Thursday, sending bipartisan legislation to President Trump that shortens sentences for some offenders and expands job training and other programs for prisoners.

The Republican-led House approved the First Step Act on a 358-to-36 vote, reflecting a major pivot by the GOP from the punitive, law-and-order stance of the 1980s to policies that emphasize rehabilitation and aim to save money.

White House officials have been planning for a signing ceremony Friday before Trump departs for Florida for the holidays. Plans call for him to invite Democrats as well as Republicans, hoping for a rare bipartisan celebration of a new law, aides said. It was unclear how an ongoing bitter fight over border wall funding that could lead to a government shutdown might affect those plans.

Trump took to Twitter shortly after the bill passed, hailing what he called “a great bi-partisan achievement for everybody.”

“When both parties work together we can keep our Country safer,” he said. “A wonderful thing for the U.S.A.!!”

During floor debate Thursday, House Judiciary Committee Chairman Bob Goodlatte (R-Va.) called the legislation “a meaningful and historic criminal justice effort,” adding that federal prisons should not be nursing homes.

While Democrats overwhelmingly supported the bill, they cautioned that it should be part of a broader effort to address inequities in the system.

“This legislation is not the end of the discussion,” said Rep. Jerrold Nadler (D-N.Y.), who will take over as Judiciary Committee chairman next month when Democrats take control of the House. “It will not solve long-standing problems with the criminal justice system . . . but it does demonstrate we can work together to make the system more fair.”

The bill would revise several sentencing laws, such as reducing the “three strikes” penalty for drug felonies from life behind bars to 25 years and retroactively limiting the disparity in sentencing guidelines between crack and powder cocaine offenses. The latter would affect about 2,000 federal inmates.

It also overhauls the federal prison system to help inmates earn reduced sentences and lower recidivism rates.

The bill, which does not cover state jails and prisons, would through reductions in sentencing do the equivalent of shaving a collective 53,000 years off the sentences of federal inmates over the next 10 years, according to the Congressional Budget Office — though some advocacy groups dispute this figure. There were about 181,000 federal inmates as of Dec. 13, according to the Bureau of Prisons.

A similar move has been afoot in many states as crime rates have dropped and officials have pursued cost-effective ways to cut the prison population.

A different version of the bill previously passed the House, but an amended version remained stalled in the Senate until last week amid concerns by some GOP senators that passage could make them look weak on crime.

As the House moved to adopt the Senate legislation, Rep. Douglas A. Collins (R-Ga.) pushed back on those concerns in his floor remarks Thursday, ticking off the names of several law enforcement groups that support the bill.

“I stand before you as a son of a Georgia state trooper,” he said. “I know this bill will help in the long run. . . . We’re helping law enforcement do their job.”

He said the same approach has worked in some conservatives states, including Georgia, as well as liberal states.

Some Democrats had pushed for a more generous bill and similar yet more expansive legislation under the Obama administration was scuttled by Republicans.

“Does [this bill] address the criminalization of poverty? No,” Rep. Cedric L. Richmond (D-La.) said during Thursday’s debate. “It leaves many sentences, unjust sentences, in place. However, there is no doubt in my mind that this bill is a positive step in the right direction.”

The bill received a boost last month when Trump endorsed it as “reasonable sentencing reforms while keeping dangerous and violent criminals off our streets.” His thinking was heavily influenced by his son-in-law and White House adviser, Jared Kushner, who has long advocated sentencing restructuring and marshaled endorsements of the bill from a diverse coalition, including law enforcement and the American Civil Liberties Union.

The bill’s passage was a personal victory for Kushner at a time when he has faced difficulties on other fronts, including scrutiny in recent months for his friendship with Saudi Arabia’s crown prince, Mohammed bin Salman.

For years, Kushner has been advocating to overhaul sentencing laws — an issue he looks at through a deeply personal lens because his father was incarcerated for more than a year at a federal prison in Alabama a decade ago.

Kushner spent months quietly pressing Trump to prioritize criminal justice policies, carving out time on his father-in-law’s schedule for meetings on the topic — including an October visit to the Oval Office by rapper Kanye West and his wife, reality-television star Kim Kardashian West, both outspoken reform advocates.

Kushner personally rallied key Republican and Democratic lawmakers to support the bill, which he pitched to the president as a rare bipartisan deal, and persuaded Senate Majority Leader Mitch McConnell (R-Ky.) to bring it to a vote.

Kushner’s allies inside the administration say the issue illustrates the presidential son-in-law’s ability to deliver results while largely avoiding the media limelight and working with a staff of just two.

Though Trump allies have celebrated the bipartisan achievement, they have also sought to use it as a cudgel against Democrats for not coming on board with other Trump agenda items.

“Another historic win for President @realDonaldTrump,” White House press secretary Sarah Sanders wrote on Twitter earlier this week after the bill’s Senate passage. “It’s been a productive two years. 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 & less time tearing the President down.”

Seung Min Kim contributed to this report.