Until Larry Krasner entered the race for District Attorney of Philadelphia last year, he had never prosecuted a case. He began his career as a public defender, and spent three decades as a defense attorney. In the legal world, there is an image, however cartoonish, of prosecutors as conservative and unsparing, and of defense attorneys as righteous and perpetually outraged. Krasner, who had a long ponytail until he was forty, seemed to fit the mold. As he and his colleagues engaged in daily combat with the D.A.’s office, they routinely complained about prosecutors who, they believed, withheld evidence that they were legally required to give to the defense; about police who lied under oath on the witness stand; and about the D.A. Lynne Abraham, a Democrat whose successful prosecutions, over nearly twenty years, sent more people to death row than those of any other D.A. in modern Philadelphia history.

In 1993, Krasner opened his own law firm, and went on to file more than seventy-five lawsuits against the police, alleging brutality and misconduct. In 2013, he represented Askia Sabur, who had been charged with robbing and assaulting a police officer. A cell-phone video of the incident, which had gone viral, showed that it was the police who had beaten Sabur, on a West Philadelphia sidewalk. Daniel Denvir, a former criminal-justice reporter at the Philadelphia City Paper and a friend of Krasner’s, recalled that, at the trial, Krasner revealed the unreliability of the officers’ testimony, “methodically unspooling their lies in front of the jury.” In dealing with such cases, Denvir said, Krasner sought to illustrate “prosecutors’ and judges’ typical credulity with regard to anything that a police officer said, no matter how improbable.” (Krasner later filed a civil lawsuit on Sabur’s behalf, which was settled for eight hundred and fifty thousand dollars. The police officers were never charged with lying on the witness stand.)

In Krasner’s spare time, he worked pro bono, representing members of ACT UP, Occupy Philadelphia, and Black Lives Matter. In 2001, his wife, Lisa Rau, decided to run for state-court judge. Krasner asked some of the activists he had represented, including Kate Sorensen, of ACT UP, for help. “We were involved with a whole community of anarchist activists—folks who generally don’t vote,” Sorensen said, “but we got hundreds and hundreds of lawn signs up all over the city.” Rau won, and later earned a reputation for challenging questionable testimony from the police.

In early 2017, when Krasner told the six-person staff of his firm that he was running for D.A., they erupted in laughter. On February 8th, he announced his candidacy with a speech in which he attacked the culture of the D.A.’s office, accusing prosecutors of embracing “bigger, meaner mandatory sentencing.” He accused the office, too, of casting a “very wide net,” which had “brought black and brown people from less prosperous neighborhoods into the system when that was in fact unnecessary and destructive.”

The president of the police union pronounced Krasner’s candidacy “hilarious.” Krasner received no mainstream-newspaper endorsements and, at first, was supported by only a few Democratic elected officials. He seemed to please almost no one in power––certainly not those in the office he hoped to lead, which has had its troubles in recent years. In 2017, the D.A. at the time, Seth Williams, was accused of accepting gifts, including a trip to a resort in Punta Cana, and later pleaded guilty to bribery, and was sent to federal prison. But few people saw Krasner as the solution. Twelve former prosecutors, nearly all of whom had worked under Williams, wrote a letter that was published in the Philadelphia Citizen: “While it might be demoralizing to work for someone who is federally indicted, imagine working for someone who has openly demonized what you do every day,” it read. “Why work for someone that reviles a career you are passionate about?”

Krasner, who is fifty-seven, is a compact man with an intense, slightly mischievous demeanor. He likes to say that he wrote his campaign platform—eliminate cash bail, address police misconduct, end mass incarceration—on a napkin. “Some of us had been in court four and five days a week in Philadelphia County for thirty years,” he said. “We had watched this car crash happen in slow motion.” Krasner often talks about how, running as a defense attorney, his opponents, most of whom had worked as prosecutors in the D.A.’s office, frequently attacked him for having no experience. At one event, they were “beating the tar out of me because I have not been a prosecutor. ‘Oh, my God! He’s never been a prosecutor!’ ” But the line of attack worked to his advantage. “You could hear people saying, ‘that’s good!’ ” Brandon Evans, a thirty-five-year-old political organizer, said. “I remember people nodding profusely, rolling their eyes, and shrugging their shoulders.”

In 2015, Philadelphia had the highest incarceration rate of America’s ten largest cities. As its population grew more racially diverse and a new generation became politically active, its “tough on crime” policies fell further out of synch with its residents’ views. During Krasner’s campaign, hundreds of people—activists he had represented, supporters of Bernie Sanders, Black Lives Matter leaders, former prisoners—knocked on tens of thousands of doors on his behalf. Michael Coard, a left-wing critic of the city’s criminal-justice system, wrote in the Philadelphia Tribune that Krasner was the “blackest white guy I know.” The composer and musician John Legend, a University of Pennsylvania graduate, tweeted an endorsement. In the three weeks before the primary, a PAC funded by the liberal billionaire George Soros spent $1.65 million on pro-Krasner mailers and television ads. Strangers started recognizing him on the street. He trounced his six opponents in the primary, and went on to win the general election, on November 7, 2017, with seventy-five per cent of the vote. He was sworn in on January 1, 2018, by his wife.

In the past ten years, violent crime across the country has fallen, but, according to polls, many people continue to believe that it has increased. President Trump’s campaign exploited the fear of “American carnage,” and the criminal-justice system of the United States, which has the highest incarceration rate in the world, seems built on this misinformation. And yet, at a local level, there are signs of change. Krasner is one of about two dozen “progressive prosecutors,” many of them backed by Soros, who have won recent district-attorney races. In 2016, Aramis Ayala got early support from Shaquille O’Neal and won a state’s attorney race in Florida, and Mark Gonzalez, a defense attorney with “NOT GUILTY” tattooed on his chest, became the D.A. in Corpus Christi, Texas. Last month, Rachael Rollins, a former federal prosecutor, became the first African-American woman to win in a Democratic primary for D.A. in Suffolk County, Massachusetts, having promised to stop prosecuting drug possession, shoplifting, and driving with a suspended license, among other crimes. Instead, she said, she would handle the cases she didn’t dismiss in other ways, by sending defendants to community-service or education programs, for example. On September 7th, President Barack Obama delivered a speech to students at the University of Illinois at Urbana-Champaign in which he referred to Krasner and Rollins: “If you are really concerned about how the criminal-justice system treats African-Americans, the best way to protest is to vote,” he said. “Do what they just did in Philadelphia and Boston and elect state attorneys and district attorneys who are looking at issues in a new light.”