The final ranked ballot count—used hardly anywhere else in the United States—showed Mirkarimi with 53.5 percent of the vote.
Sharmin Bock, another Iranian-American who was one of five candidates running for district attorney, came in a strong third in that race.
The only citywide offices on the ballot in San Francisco were mayor, sheriff and district attorney.
Mirkarimi has been a member of the San Francisco Board of Supervisors since 2005. Due to term limits, he was not eligible to run for re-election next year and ran for sheriff this year instead.