WASHINGTON — A bipartisan group of senators has reached a tentative deal on the most substantial rewrite of the nation’s sentencing and prison laws in a generation, giving judges more latitude to sidestep mandatory minimum sentences and easing drug sentences that have incarcerated African-Americans at much higher rates than white offenders.

The lawmakers believe they can get the measure to President Trump during the final weeks of the year, if the president embraces it.

The compromise would eliminate the so-called stacking regulation that makes it a federal crime to possess a firearm while committing another crime, like a drug offense; expand the “drug safety valve” allowing judges to sidestep mandatory minimums for nonviolent drug offenders; and shorten mandatory minimum sentences for nonviolent drug offenders, according to draft text of the bill obtained by The New York Times.

It would also retroactively extend a reduction in the sentencing disparity between crack and powder cocaine signed into law in 2010, potentially affecting thousands of drug offenders serving lengthy sentences.

“We have the clearest path forward that we have had in years,” said Holly Harris, the executive director of the Justice Action Network, a bipartisan coalition arguing for an overhaul. “This would be the first time that these members have voted on a piece of legislation that turns away from the lock-’em-up-and-throw-away-the-keys policies of the 1990s. That is groundbreaking.”

Lawmakers and outside advocates involved in the push expect Mr. Trump to render his judgment on the package as soon as this week. Jared Kushner, the president’s son-in-law and the leading voice within the White House for the changes, is likely to brief Mr. Trump on the bill during a broader discussion of legislative priorities with top policy officials on Tuesday, according to one senior administration official, who was granted anonymity to discuss the plans. And at least two influential Republican senators were lobbying the president in its favor.

Senator Mitch McConnell of Kentucky, the majority leader, has told the senators he will bring the package up for a vote if they can show they had the support of at least 60 senators. Speaker Paul D. Ryan of Wisconsin, a vocal advocate of such changes, committed to putting the compromise on the House floor in a lame-duck session that begins on Tuesday if Mr. Trump endorses it and it can clear the Senate.

“Speaker Ryan has long advocated for criminal justice reform,” said AshLee Strong, a spokeswoman for Mr. Ryan. “The House passed legislation earlier this year, and we are hopeful the Senate will act so we can get a bill to the president’s desk.”

The support of the famously mercurial Mr. Trump is by no means guaranteed. But if they can secure an endorsement, senators say they can move quickly on the kind of bipartisan achievement that has eluded Mr. Trump — and bedeviled senators and outside advocates of the overhaul for years.

The effort has brought together an unlikely coalition of advocacy groups from the left and the right, including the billionaire conservative brothers Charles G. and David H. Koch and the American Civil Liberties Union. But with the arrival of the Trump administration and its return to tough-on-crime policies, many believed the chances of changing federal law were all but shot.

The bill, called the First Step Act, is more modest than the much-trumpeted set of changes that stalled in the Senate last term, but its provisions are still far-reaching and could win support across the ideological spectrum. It creates a suite of programs and incentives intended to reduce recidivism and prohibits the shackling of female inmates while pregnant, among other prison-focused measures.

In contrast to the 2015 proposal, the elimination of the “stacking” provision and the reduction of mandatory minimums for nonviolent offenders would not apply retroactively — a concession by Democrats that greatly narrows the impact of the changes for the current prison population.

Image

Jared Kushner, Mr. Trump’s son-in-law and senior adviser, has been the leading voice within the White House for the overhaul.CreditAl Drago for The New York Times

The latest compromise was crafted by Senators Charles E. Grassley, Republican of Iowa; Richard J. Durbin, Democrat of Illinois; and Mike Lee, Republican of Utah, in conjunction with Mr. Kushner. Those senators won a promise from Mr. Trump in August that he would consider backing a bill during the lame-duck session. Mr. Grassley, the Judiciary Committee chairman, and another senior Republican on that committee, Lindsey Graham of South Carolina, have lobbied Mr. Trump in the months since.

If Mr. Trump supports the package, senators will still be up against a rapidly closing legislative window — Congress is set to break in mid-December — and certain opposition from conservative Republicans in both the Senate and the House.

Democrats could also throw up roadblocks if liberals think they could get a better deal once Democrats take control of the House.

If Mr. Trump does not back the measure, lawmakers concede its chances of advancing this Congress are almost none.

But advocates of changes to the sentencing and prison laws see a path to passage. The Fraternal Order of Police, the country’s largest police organization, announced on Friday that it would support the bill. The National Sheriffs’ Association, another key constituency, appears to have dropped some of its objections after a meeting with Mr. Kushner late last week, the senior administration official said.

“We have a bill that will make our streets and neighborhoods safer, our police will be better protected and improve the ability of our criminal justice system to effectively rehabilitate offenders,” Chuck Canterbury, the police order’s president, said in a statement.

Lawmakers may have also gotten a boost with the departure of Jeff Sessions as attorney general last week. Mr. Sessions had used his post to order federal prosecutors to pursue the toughest possible charges and sentences for crime suspects, reversing Obama-era efforts to ease such penalties for some nonviolent drug offenders. And he vigorously opposed legislative compromise, going head-to-head not only with Mr. Grassley but also with Mr. Kushner.

Mr. Kushner has had several meetings with Matthew G. Whitaker, the new acting attorney general, who has signaled that he is open to the changes. The effort could be revived in the next Congress if he and allies are unable to succeed in the short term.

Mr. Kushner has also traveled with Vice President Mike Pence in recent days to brief the vice president on the latest developments, the administration official said.

If Mr. Trump offers his support this week, Mr. Grassley would introduce the bill within days. Mr. Durbin would then likely endorse it and lobby fellow Democrats.

Emily Hampsten, a spokesman for Mr. Durbin, said he was “negotiating in good faith, but there won’t be any agreement on a criminal justice reform compromise unless and until President Trump supports it and asks the Republicans who control both chambers of Congress to move it forward.”

The senators believe they can win over most Democrats and, with cover from Mr. Trump, a large block of Republicans. But they fear outspoken conservative opponents to liberalizing sentencing laws, especially Senator Tom Cotton of Arkansas, could pull Mr. Trump out of their camp.

Then there is the House, which passed a prison bill that excluded any modifications to sentencing laws this year by an overwhelming margin. The addition of sentencing changes is likely to sweeten the deal for Democrats and turn off some Republicans. A Democratic strategy of delay until next year comes with substantial risks — Senate leaders and the White House could withdraw support. A spokesman for Representative Nancy Pelosi of California, the Democratic leader, declined to comment.