WASHINGTON -- There haven't been many issues in which U.S. Sen. Cory Booker and President Donald Trump see eye-to-eye on. Indeed, Booker pledged to stand up to Trump even before the president was inaugurated.

Not now. Booker, close to fulfilling one of his top priorities since coming to Washington, aligned himself with Trump and lawmakers of both parties and signed onto to legislation overhauling criminal justice laws.

Booker, D-N.J., became one of the six original Senate sponsors of the First Step Act, which is designed to reduce the number of nonviolent offenders behind bars, who are disproportionately minority and often there due to drug crimes.

"It will affect the lives of thousands of people who have been abused and wronged by a broken criminal justice system," Booker told NJ Advance Media.

Trump and son-in-law Jared Kushner have sought changes to the criminal justice system, and the president embraced the legislation at the White House, surrounded by U.S. senators and representatives of groups pushing for the measure.

Criminal justice is one issue that Booker, a potential challenger to Trump in 2020, has reached far across party lines to achieve, including co-sponsoring legislation with U.S. Sens. Mike Lee, R-Utah, and Rand Paul, R-Ky.

The alignment of Trump and Booker is in contrast to the barbs they have tossed at each other. Booker called for Trump's resignation a year ago and said the president left him "outraged and disgusted'' after blaming both neo-Nazi protesters and those who opposed them for violence during a white supremacist march in Charlottesville, Virginia.

Trump, meanwhile, made Booker a frequent foil on the campaign trail this fall, attacking his record as mayor of Newark.

On this bill, Booker also found himself on the same side as Senate Judiciary Chairman Chuck Grassley, with whom he clashed repeatedly during the confirmation hearings for U.S. Supreme Court Justice Brett Kavanaugh.

The legislation would allow judges to hand out lighter sentences to those convicted of nonviolent drug crimes, reduce to 25 years from life imprisonment the automatic sentence imposed on offenders convicted for a third time, stop charging nonviolent offenders with an extra crime if they are carrying a gun, and prevent most juveniles from being put in solitary confinement.

Another provision would allow prisoners who were convicted of crack cocaine offenses before the 2010 law that imposed similar penalties for both powder cocaine and crack cocaine use to petition for lighter sentences.

Booker's name noticeably was absent from the early reports about a deal, even as he was involved behind the scenes while Grassley, R-Iowa, and Senate Democratic Whip Richard Durbin of Illinois ironed out a final agreement.

Booker came on board after the solitary confinement and other sentencing provisions were added. He said the bill wasn't perfect but definitely was a good start. Besides Booker, Grassley and Durbin, the bill's original sponsors were Lee and U.S. Sens. Lindsey Graham, R-S.C., and Sheldon Whitehouse, D-R.I.

"I'm proud that we've gotten to this point," Booker said. "We have a bipartisan bill that looks like it has a pathway to passing."

My full statement on my sponsorship and support of the comprehensive criminal justice reform compromise introduced today in the Senate: https://t.co/WmJFBZ8S5s pic.twitter.com/0tphYBzKIV — Sen. Cory Booker (@SenBooker) November 15, 2018

The original bill, which passed the House in May, focused solely on those already behind bars. It expanded programs to help inmates after they were released from prison, sped up early release for some, provided treatment for those addicted to opioids, required prisoners to be housed closer to home, and prevented pregnant women from being shackled.

Booker, whose work on criminal justice was recognized for his work when President Barack Obama came to Newark in November 2015, initially opposed the House measure because of prison provisions were weak and the bill did not address sentencing at all.

So did Durbin and other Democrats, most notably Rep. John Lewis of Georgia, the civil rights icon.

"Prison reform will fail if we do not address the mandatory minimum sentences that have filled our prisons with individuals convicted of nonviolent offenses," the lawmakers wrote to their colleagues in May.

By co-sponsoring the legislation, Booker, D-N.J., joined not only Trump -- a potential 2020 White House opponent -- but also Grassley, with whom he clashed repeatedly during the confirmation hearings for U.S. Supreme Court Justice Brett Kavanaugh.

The bipartisan group of sponsors also included Durbin and Republican U.S. Sens. Mike Lee of Utah and Lindsay Graham of South Carolina. A long list of civil rights and other organizations, including those led by billionaire energy executives Charles and David Koch, were among those urging changes in criminal justice laws.

Booker, Grassley and Durbin were among the authors of a 2016 criminal justice bill that failed when Senate Majority Leader Mitch McConnell, R-Ky., refused to bring it up for a vote.

There's no guarantee that either McConnell nor outgoing House Speaker Paul Ryan, R-Wis., will allow a vote on this measure either, even as Trump earlier this week urged Congress to act.

Indeed, Grassley took to Twitter Friday to encourage McConnell to act.

DEALMAKER @realDonaldTrump can get a big bipartisan deal done THIS YEAR on crim justice reform Plenty of time to pass First Step Act in December Will GOP senators & Ldr McConnell stand in Pres Trump’s way of achieving major bipartisan victory or join in historic + popular reform? — ChuckGrassley (@ChuckGrassley) November 16, 2018

Lawmakers return to Washington after Thanksgiving, with their top priority being a spending bill to prevent a third government shutdown under Trump's watch.

"When Republicans and Democrats talk, debate, and seek common ground, we can achieve breakthroughs that move our country forward and deliver for our citizens," Trump said.

"I urge lawmakers in both the House and Senate to work hard and to act quickly and send a final bill to my desk," he said. "And I look very much forward to signing it. This is a big breakthrough for a lot of people."

I am grateful to be here today w/ Members of the House & Senate who have poured their time, heart and energy into the crucial issue of Prison Reform. Working together w/ my Admin over the last two years, these members have reached a bipartisan agreement...https://t.co/wflidv2cZr — Donald J. Trump (@realDonaldTrump) November 14, 2018

Jonathan D. Salant may be reached at jsalant@njadvancemedia.com. Follow him on Twitter @JDSalant or on Facebook. Find NJ.com Politics on Facebook.