In a closely fought race ultimately decided by only 2,825 votes out of over 190,000 cast, deputy San Francisco public defender Chesa Boudin, running with the support of the Libertarian Party and Green Party among other community groups, has been declared San Francisco’s next district attorney.

Boudin’s top campaign issues included an end to money bail, mass incarceration, and the “War on Drugs”, and he also supports decriminalization of sex work. He was strongly opposed by the local police union, the Police Officers Association, which reportedly spent over $625,000 in attack ads against him. (This reporter personally received three glossy POA-funded mailers with messages including “Electing Chesa Boudin will put our families at risk!” and “According to Chesa Boudin, drunk driving is a victimless crime” – the former with the last three words in red, and the latter in all caps.)

With former district attorney George Gascon not seeking reelection, the race had been the first for the office in over a century without an incumbent. But in a surprise move, Gascon abruptly resigned in early October, allowing SF mayor London Breed to appoint her preferred candidate, Boudin’s chief rival Suzy Loftus, as the interim D.A. Because many voters have a bad habit of automatically supporting incumbents, this was seen as giving Loftus a major boost and was widely criticized as a political move interfering with the election.

There were two other candidates in the race, Nancy Tung and Leif Dautch – both, like Loftus, current or former prosecutors, so with ranked choice voting in effect, Boudin faced a tough challenge. On the first round of voting he was leading, with election night totals on Tuesday giving him 35% of the first-choice vote compared to 31% for Loftus, but after the other two candidates were eliminated and their supporters’ votes transferred to the remaining candidates, Loftus had pulled ahead, first by a mere 240 votes and then by 879 votes. Many ballots remained to be counted however, and as later returns continued to come in, Boudin regained the lead, and over the weekend Loftus conceded when it became apparent she no longer had a mathematical chance of victory.

As widely reported, Chesa Boudin is the child of parents who formerly belonged to the Weather Underground and spent years in jail for their nonviolent roles in an attempted armed robbery conducted by members of the radical group. Boudin’s father in fact remains incarcerated, and Boudin was flying back to SF from visiting him in jail when he found out he had won the election.

Boudin also had the support, which he prominently featured on his website, of longtime independent U.S. Senator Bernie Sanders who is currently seeking the Democratic Party’s presidential nomination. His win is the latest in a wave of progressive district attorneys recently being elected in cities like Philadelphia and Queens, New York, as public concerns over police abuses continue to make themselves felt.