The U.S. locks up more of its citizens than any nation in the world, and far too many of them are African American and Hispanic men imprisoned for non-violent drug crimes. The sad state of the criminal-justice system has become, over the last decade, a crisis lamented with nearly equal measure of sorrow by Democrats and Republicans alike. To hear the politicians tell it, mass incarceration is both a financial drain on the government at all levels, and a moral stain that consigns families and entire communities to a cycle of poverty.

Yet despite no shortage of proposals for reform in recent years, Congress has done virtually nothing. That may, finally, be about to change, as an emboldened President Obama eyes what might be the last major addition to his domestic legacy in the White House.

Speaking at a press conference last week, the president was asked how he might follow the remarkable string of victories he earned in late June, which included a congressional win on trade, a pair of legacy-setting Supreme Court decisions, and a widely-praised eulogy in Charleston. He ticked off several unchecked boxes on his economic agenda, including a major infrastructure bill and enactment of his proposals to boost job training and access to community college. But the big-ticket item Obama mentioned that actually holds the most promise in the Republican Congress is a long-awaited overhaul of the nation’s criminal-justice system. “We’ve seen some really interesting leadership from some unlikely Republican legislators very sincerely concerned about making progress there,” the president observed.

He’s right. The bipartisan coalition pushing to reduce incarceration rates in the world’s most crowded prison system has been building for years, bringing together ardent foes like the Koch Brothers and the ACLU, and Rand Paul and Cory Booker, among others. Various proposals to eliminate mandatory-minimum sentences for certain drug crimes, and to keep young, nonviolent offenders from receiving long, crippling prison sentences have circulated for a while without going anywhere. Yet that movement is cresting now, providing what lawmakers and advocates say is a genuine opportunity to enact legislation before the end of the year. “I am very optimistic that we will get something done. If you had told me a couple years ago, I would not have believed it,” said Representative Elijah Cummings, a Maryland Democrat who is not known as a congressional Pollyanna.

As usual, however, Cummings’s rosy view comes with a key caveat repeated by other advocates I interviewed: the looming presidential election. “I think the stars have aligned,” Cummings said. “I do believe, however, that if we don’t get it done now, I don’t know that the stars will align like this again.” Obama talked up the prospect of criminal-justice reform just a few days after lawmakers in the House unveiled the most ambitious and comprehensive proposal to modernize the system to date. Over the weekend, The New York Times reported that Obama was soon likely to commute the sentences of dozens of nonviolent drug offenders—an act of presidential clemency unprecedented in scope that would seek to galvanize the push for reform in Congress.

What distinguishes criminal-justice reform from other bipartisan efforts is the wide range of motivations that have led a diverse coalition of people to draw the same conclusion: There should be a lot fewer people in U.S. prisons. Fiscal hawks, including the anti-tax activist Grover Norquist, frequently cite the exploding costs and inefficiency of the criminal-justice system. According to an oft-repeated statistic from the Pew Charitable Trusts, federal spending on prisons rose sevenfold over the last three decades, from less than $1 billion (adjusted for inflation) in 1980 to nearly $7 billion in 2013. That increase was propelled by a corresponding rise in the number of inmates and the number of prisons.

Another libertarian complaint is “overcriminalization.” Congress keeps making new laws, which have led to thousands of different rules in the penal code that can be broken—and prosecuted. “There are now so many administrative regulations that carry criminal penalties that nobody knows how many there are,” said Representative Jim Sensenbrenner, a Wisconsin Republican and co-author of the SAFE Justice Act, a comprehensive proposal introduced in June.

Yet those arguments have faded to the background in recent months as the deaths, at the hands of police, of young black men in Ferguson, Staten Island, and Baltimore—along with the suicide of Kalief Browder in New York—have once again illuminated the inequities that draw a disproportionate number of African American and Hispanic men into the criminal-justice system at an early age. The financial cost is significant, acknowledged Senator Mike Lee, the Tea Party conservative who has joined with Democrats to push for a reduction in mandatory-minimum sentences. “The even more significant and more compelling component of this is the human cost,” Lee told me, “the number of husbands, fathers, sons, uncles, brothers throughout the country who are locked up for sometimes years and decades at a time.”

And as Obama and others have noted, even a short prison sentence can be catastrophic to a person’s future chance of success. Many employers won’t hire people with a criminal record, and they might even be ineligible for many educational or job training programs, leaving them with few options. “It is not a sentence for a week or a year. It is a sentence for a lifetime,” Cummings said. “There are certain states where you cannot become a barber if you have a criminal record. We are creating a situation where people have nowhere to go but a life of crime.”

The question House and Senate lawmakers are now wrestling with is the scope of legislation. Proposals in the Senate have tended to focus on narrow aspects of criminal-justice reform. The Smarter Sentencing Act, introduced by Lee and Senator Dick Durbin of Illinois, the second-ranking Democrat, would reduce mandatory-minimum sentencing for nonviolent-drug crimes while increasing penalties for drug offenses linked to sexual abuse or terrorism. Another bill from Senators John Cornyn, a Texas Republican, and Sheldon Whitehouse, a Democrat of Rhode Island, would tackle so-called re-entry reform. Based on successful programs in their home states, the proposal would allow inmates to earn time off their sentences by participating in programs, such as prison jobs, designed to reduce recidivism.

In the House, criminal-justice reform advocates (including Koch Industries and the ACLU) have rallied around the broader bill authored by Sensenbrenner and Representative Bobby Scott, a Virginia Democrat. The SAFE Justice Act addresses both mandatory minimums and recidivism programs, but it also includes a raft of other changes aimed at beefing up probation programs, preventing wrongful convictions by offering more protections for poor defendants, and making it easier for elderly inmates to secure early release. The bill also addresses what advocates call the “over-federalization” of crime, in which offenses that could be prosecuted in state court are often transferred to federal jurisdiction, where the penalties are stiffer. Sensenbrenner said the proposal emerged out a task force that he and Scott led that held 10 hearings over the last two years and studied many reform efforts that have worked at the state level.

For Virginia Sloan, president of the Constitution Project, the sheer breadth of the proposal is something of a watershed moment in the 20-year effort to roll back tough-on-crime laws that many Republicans and Democrats now concede went too far. “We just have not seen this level of bipartisanship in a long time, if ever,” Sloan told me. “People are now looking back at those bills and saying, ‘It doesn’t matter what party you were from: We made mistakes. We went in the direction of toughness and finality rather than fairness and reliability and getting it right.’”

In Congress, not even consensus is a guarantee of success. After Obama’s reelection in 2012, advocates for comprehensive immigration reform were never more confident that their moment had come, and despite the passage of legislation in the Senate, the effort stalled out in the House. Neither Speaker John Boehner nor Senate Majority Leader Mitch McConnell have said much either way about criminal-justice reform, but the congressional middle men—Judiciary Committee Chairmen Charles Grassley in the Senate or Bob Goodlatte in the House—are more traditional law-and-order Republicans who have been resistant to the issue in the past.

There are indications, however, that at least Grassley may be shifting. In March, he delivered a lengthy speech denouncing efforts to reduce mandatory minimums, mocking supporters for promoting the idea “that poor, innocent, mere drug possessors are crowding our prisons.” In recent days, his office has confirmed reports by Politico and BuzzFeed that he is working with Democrats on legislation that could include changes to mandatory minimum sentences. In the House, Goodlatte has set up a separate, “step-by-step” process for considering the issue over the next several months. That’s ominous news for advocates, since it’s the same process Goodlatte used to effectively slow-walk immigration reform to death in 2013. Sensenbrenner, for example, criticized the chairman’s intention to split up his bill into multiple pieces. “This is a way to make sure all of this fails,” he told me.

If the failure of immigration reform is a cautionary tale for advocates of criminal-justice reform, then the more recent success of legislation reining in the NSA could be a roadmap. The coalition of Democrats and libertarian-minded Republicans is similar, and it is lead in part by Sensenbrenner, a 36-year veteran of the House, it kept gathering support until it became impossible for the resistant party leadership to ignore. That effort took more than a year, however, and with the presidential campaign threatening to interrupt the bipartisan comity that’s broken out on Capitol Hill, there’s a reason President Obama needs lawmakers to move quickly. If he wants to notch one more lasting victory for his domestic legacy, he might only have a few more months to get it done.