On Monday, jury selection was set to begin in the trial of the current district attorney, Seth Williams, a Democrat, on charges that he sold his influence in exchange for lavish gifts and stole from his mother. And despite some recent overhauls, Philadelphia still has one of the highest incarceration rates of any urban center in the country.

Mr. Krasner also credited his victory in part to national politics, saying that Philadelphians had cast their votes against the Trump administration’s crackdown on illegal immigrants and signs of a rollback of federal oversight of police departments that routinely violate civil rights.

“When you’re 56 and you see the worst president of your lifetime and the worst attorney general of your lifetime trying to reverse good things that date back to the ’60s,” Mr. Krasner said, “you might just have to do something about it.”

And so he has offered up a menu of initiatives aimed at fighting what he called “the criminalization of poverty.” He has promised to cut down on the prosecution of minor cases, divert drug addicts into treatment and ignore, where appropriate, what he described as draconian sentencing guidelines. He has also said he would abolish money bail — which often leads to the jailing of poor defendants while wealthier ones go free — and would decline to seek charges in any case he deemed to be based on an illegal stop and search.

This agenda has left an opening for his opponent in the November election, Beth Grossman, a career local prosecutor who was for years a Democrat before becoming the Republican nominee. Ms. Grossman, too, has promised to overhaul the city’s justice system by cutting back on the criminal prosecutions of small-time drug offenders. But she chided Mr. Krasner for going too far.