Larry Krasner, a left-wing civil rights lawyer, has won the Democratic primary for (and thus almost certainly the office of) Philadelphia district attorney. This is a very big deal: one of the city’s most high-profile critics of the criminal justice system will now have a leading role in administrating and, hopefully, transforming it.

Philadelphia is the city where the former DA Lynne Abraham, dubbed “the deadliest DA” for her zealous embrace of the death penalty (though no one she sent to death row was ever actually executed), ran the office for nineteen years.

It’s the city where police-chief-turned-mayor Frank Rizzo reigned throughout the 1970s, a human embodiment of reactionary backlash politics with a reputation for meting out beatings as a rank-and-file cop and who took glee in a public strip search of Black Panthers. He reportedly once pledged to make “Attila the Hun look like a faggot.”

It is a city where police officers and prison guards have committed abuse with impunity, and where a drug war vacuums people of color into the prison system while public schools careen from fiscal crisis to crisis and overdose deaths skyrocket.

The Philadelphia that voted Rizzo and Abraham into office, however, is gone — at least as a governing majority. Krasner’s win was powered by a coalition of activists from social movements he fought for in court over decades: Black Lives Matter, Occupy Philly, ACT UP, and Republican National Convention protesters. He has repeatedly sued the police. Now, somewhat awkwardly, he will prosecute alleged criminals. But he promises to do so in a different way than past prosecutors.

Krasner’s vision for the criminal justice system is one “that makes things better, that is just, that is based on preventing crime, and is based on building up society rather than tearing it apart,” he said in addressing a raucous crowd of supporters in Center City’s Gayborhood, not far from his law office.

Philadelphia politics, like those in cities across the country, are shifting rapidly. Not long ago, Krasner would have been fatally attacked for being on soft on crime. This year, those charges didn’t stick, in part because there wasn’t a single self-professed law-and-order candidate in the race. Krasner dragged the field to the left and everyone else struggled to follow.

A few years back, a white candidate like Krasner would have found it impossible to win in a crowded seven-candidate field with just one black candidate. This year, black civil rights activists and many political leaders backed the left-wing white guy.

Krasner’s decisive win — a local anchor noted that he “obliterated the field,” winning by a margin of eighteen points ahead of his nearest rival — is historic. It is the strongest evidence yet that the grassroots movement activated by the Bernie Sanders campaign is capable of winning critical elections. And it should inspire activists and organizers nationwide to target mass incarceration where it begins: with local police departments, courtrooms, and, critically, prosecutors.

“Ultimately, this is not about any individual in the way that the movement around Bernie was really not about any individual,” Krasner tells me. “It was about a platform that reflects common values of ordinary people. And I view myself as an ordinary person. This suggests that you don’t have to have the last name of someone else who’s been in elected office before you, you don’t have to be rich, you don’t have to follow traditional career choices in order to be elected to office.”

Krasner’s win resulted from a citywide grassroots mobilization, the support of a few critical Democratic Party powerbrokers and unions, progressive groups like Our Revolution, the Working Families Party, and Color of Change. It’s also because of, in no small part and not without controversy, the reported $1.45 million that liberal billionaire George Soros spent on a pro-Krasner political action committee.

But the most basic reason for this victory is that Krasner charged through a political opening that the city’s political and media establishment didn’t even know was there.

Outgoing DA Seth Williams is under federal indictment for corruption and not seeking reelection. But his more serious failings were more routine and rarely commented on by the press (save for the now-deceased alt-weekly, my former employer, the Philadelphia City Paper): impunity for police beatings, perjury and illegal searches, keeping defense lawyers in the dark about bad cops’ records, resistance toward righting wrongful convictions, the seizure of people’s property even when they had not been convicted of a crime and, most importantly, a general operating philosophy that prized convictions and long sentences above all else.

In recent years, reform prosecutors have won in other jurisdictions, but this would be the first time in recent memory that a civil rights lawyer who has spent his career fighting prosecutors and bad cops has won such an office. I recall that I first met Larry in early 2013 when he defended a West Philadelphia man named Askia Sabur, surreally accused of assaulting a police officer even though a YouTube video showed that it was a police officer who viciously assaulted him. As police were on the stand, obviously lying, Krasner methodically took him apart under cross-examination and made the assistant district attorney like a fool.

Krasner is a master litigator, but using this job to tackle mass incarceration — and resisting the conservatizing structural pressures that come along with occupying the DA’s office — will prove far more difficult than any of his past cases.

Mass incarceration is locked into the criminal justice system and won’t be easy to undo. Philadelphia remains a remarkably violent city, and easing sentences for violent offenders remains an extremely controversial proposition (though one that is absolutely necessary to tackle mass incarceration).

Krasner wants to reduce the population of the Philadelphia Prison System, the city jail, so that funds for education and other programs will be freed up. To do that, he will have to cut the population sharply enough to fire prison guards and close a jail facility — which could put him into conflict with the guards’ union. Their local is part of an umbrella city employees union, AFSCME District Council 33, which actually endorsed Krasner. It’s unclear how internal union dynamics led to them backing Krasner. But Krasner tells me that it’s also possible that prison guards could be shifted to work doing pre-trial supervision under a system in which cash bail had been eliminated.

What is clear is that John McNesby, head of the city’s Fraternal Order of Police Lodge #5, views Krasner as an enemy.

Putting together a team of supervisors and line prosecutors who are committed to reform — and not sabotaging his efforts through fighting his every move — won’t be easy. McNesby, the police union head, not long ago declared the very prospect of a Krasner candidacy to be “hilarious.” He has already called Krasner supporters who chanted against police last night “parasites of the city,” accused Krasner of running an “anti-law enforcement” campaign and even issued a not-so-veiled threat of a police slowdown.

Krasner might, however, find room to collaborate with Police Commissioner Richard Ross. Philly police chiefs have often chafed at FOP power, and having a DA cracking down on misconduct could strengthen a brass push for internal reform.

Finally, Krasner still must still face Republican Beth Grossman in November’s general election. But that is likely a foregone conclusion: Philadelphia is a heavily Democratic city where the action takes place in the primary. It’s also possible that an independent could still enter the race, though that seems less likely now that he’s won by such a crushing margin.

One other possible surprise development: If Williams resigns or is forced from office, city judges will appoint an interim DA — and it’s entirely unclear if that would be Krasner or someone else. It’s also possible that Republicans could put up a more A-list candidate than little-known Grossman. After Krasner’s win, it’s worth thinking through unusual possibilities.

The local level is where the fight must be won. Donald Trump and Attorney General Jeff Sessions are fighting to revive mass incarceration nationally. But an estimated 1,330,000 people are incarcerated in states compared to just 197,000 in federal prisons, with an additional 630,000 locked up in local jails — often simply because they can’t afford cash bail.

As of April 30, an estimated 49,916 people were locked up in state prisons, 28 percent of them from Philadelphia. The Philadelphia Prison System holds roughly 6,600. Trump and Sessions are no doubt dangerous, but it is district attorneys in heavily Democratic cities that have played the lead role in meting out the lengthy sentences that have made mass incarceration such an unbearable reality.

In Philadelphia, Krasner and the reform forces behind him will soon have a chance to tear that system out by the roots. It won’t be easy. But if he can accomplish that in Philly, you can do it in your city, too.

As Krasner remarked, “There is a consensus around progressive values that is starting to take over local elections and soon enough will be taking over a national election, as it should.”