From immigration to tax cuts to who won Florida, there is very little that Republicans and Democrats seem to agree on these days. But there may be one thing: the need to repair the nation’s criminal justice system.

It is a cause that has made for strange alliances, including the liberal Center for American Progress, the conservative Koch brothers, law enforcement groups, Kim Kardashian and now, President Trump, who on Wednesday endorsed a bill that would improve prison conditions and lower some sentences.

The view that punishment is too harsh, and rehabilitative measures too scarce, is broadly supported in public opinion polls, especially as crime has hovered at a 20-year low. That popular support has translated into political backing. “Out in the real world where people live, it’s not even controversial anymore,” said Mark Holden, who leads Koch Industries’ work on criminal justice issues.

Of course, not all the everyday people and the politicians who represent them arrived at this shared conclusion via the same path. The left is persuaded by vast racial disparities and the fact that the United States is a global outlier, with the world’s highest incarceration rate. Those on the right often point to unsustainable costs. The policy wonks arm themselves with reams of data on the system’s failure to lower recidivism or protect from wrongful conviction.

And, somewhere in the mix, is the notion of redemption and second chances.

The bill endorsed by Mr. Trump on Wednesday has been years in the making, bolstered by state-level changes — often led by Republicans in party strongholds like Georgia, South Carolina, Oklahoma and, more recently, Louisiana — that repeatedly demonstrated that prison populations could be reduced with no increase in crime.

The trend can be traced back to Texas in 2007, when Rick Perry, then the governor, saw a projection that the state would need 14,000 more prison beds at a cost of more than half a billion dollars. Marc Levin, a lawyer, had recently started a criminal justice program at a conservative think tank, the Texas Public Policy Foundation, and he was ready with an alternative: treatment and drug courts that would give judges an alternative to locking people up.

“There was a lot of luck involved that it turned out in 2007 things all came together,” Mr. Levin recalled. “And obviously, it was Texas — if Vermont had done this, no one would have noticed.”

Instead, Mr. Levin found himself fielding inquiries from state after state.

“Tough on crime” had been a political mantra. Mr. Levin called his campaign Right on Crime. Later, the Obama administration would chime in with Smart on Crime.

Advocates acknowledge that they vary their tactics depending on the audience. “It’s common sense but we look at it through three different lenses: It’s a moral, constitutional and a fiscal issue,” Mr. Holden said. With other sea changes, he said, “People have seen some type of moral outrage — abolition, suffrage, civil rights, marriage equality, they’ve all been, basically, people coming together from all sides.”

Image

A prison in Springville, Ala. The roots of bipartisan consensus date back more than a decade.CreditWilliam Widmer for The New York Times

The messenger matters as well: Public polling has shown that people trust police officers the most, then the formerly incarcerated.

The Koch brothers were attracted to the topic because of the proliferation of criminal statutes — too many on the federal level to even count, Mr. Holden said. But they went on to tackle issues like high bail and poor legal representation for the poor. Mr. Levin, for his part, thought that if conservatives were going to be skeptical of the government’s role in areas like education and welfare, they should also be willing to apply that scrutiny to criminal justice.

He also saw an argument that appealed to the Tea Party’s distaste for government interference. “There’s a group of people that could be self-sufficient if we just remove the barriers that the government’s imposed,” he said, referring to laws that bar former felons from obtaining certain kinds of licenses. “We’re doing more harm than good by keeping people in prison who don’t need to be there.”

Crime has long been an issue in election season. Few political veterans can forget the 1988 presidential campaign in which President George H.W. Bush bashed Michael Dukakis for releasing a prisoner, Willie Horton, on furlough who later went on to commit assault, armed robbery and rape.

“Both parties were competing for who can be the most tough on crime throughout the 1980s and ’90s, and then the Republicans came to their senses first, for financial reasons,” said Inimai Chettiar, director of the Brennan Center for Justice. “So now you’re going to have this happen, if it happens, under a very conservative president.”

In Ms. Chettiar’s view, reining in the criminal justice system did not become a mainstream Democratic issue until 2016, when Hillary Clinton came out in favor of it and Bill Clinton apologized for the 1994 bill.

Bipartisanship on the need for change has helped inoculate candidates from Willie Horton-style attacks, and conservatives have been willing to give liberals political cover.

In 2012, when Gov. Jerry Brown of California was considering a bill that would allow reconsideration for people sentenced to life without parole as juveniles, his office asked Right on Crime for help, Mr. Levin recalled. Newt Gingrich, the former Republican House speaker, and Pat Nolan, a Republican legislator, became active in prisoner advocacy after serving time on a racketeering charge, wrote an op-ed in The San Diego Union-Tribune in favor of the bill, and ten days later Mr. Brown signed it into law.

“There are no politicians more popular than Donald Trump in Kentucky,” said Holly Harris, executive director of U.S. Justice Action, a main proponent of the bill. “I can say that because I live there.”

A version of this article appears in print on , on Page A18 of the New York edition with the headline: An Issue That Unites the Left, the Right, the Kochs, a Kardashian and Trump. Order Reprints | Today’s Paper | Subscribe