Updated

Mayor Ed Lee held a commanding lead in the mayor's race against a diverse slate of 15 candidates, but because he didn't garner a majority in Tuesday's election the city's instant runoff system has kicked in.

Lee, a former city administrator who replaced then-Mayor Gavin Newsom when he became lieutenant governor in January, was ahead with nearly 31 percent of the vote. City Supervisor John Avalos followed with nearly 18 percent; and City Attorney Dennis Herrera was trailing with 11 percent.

But even with all the precincts counted late Tuesday, it will be at least Wednesday before the city's 468,000 registered voters know the winner because a voter-approved election system requires that the winner get 50 percent plus one vote. Since Lee didn't claim more than half the vote, a system in which voters rank their top three candidates will decide the winner.

Still, Lee was jubilant outside his campaign party Tuesday night.

"I worked so hard to make sure that we continue with the success this city knows so well," said Lee, who would become the city's first elected Asian-American mayor. "I'm going to work tomorrow, tired or not, because this city is worth the sacrifice."

It appeared the city's other top elected positions -- district attorney and sheriff -- would also be decided by the ranked-choice voting system.

Lee's formal election or that of any of the several other Asian-American candidates on the ballot would symbolize a milestone for the city's Asians, who make up a third of the population but have traditionally been underrepresented.

Tuesday's election also asked voters to choose between dueling pension reform proposals for city workers, one promoted by Lee and the unions, and the other by his rival, Public Defender Jeff Adachi. Lee's Proposition C was far outpacing Adachi's Proposition D.

Former police chief George Gascon was winning his bid to keep his seat as district attorney with more than 44 percent of the vote. David Onek, former head of the San Francisco Police Commission, was trailing with 23 percent.

Longtime Sheriff Michael Hennessey is retiring after three decades of wearing the badge and City Supervisor Ross Mirkarimi was leading the race with 38 percent of the vote.

Lee had been the favorite in the polls. The civil rights attorney-turned-bureaucrat has worked for four mayors in five city apartments for 22 years, and his likeability ratings were consistently high. Though some of his campaign supporters are under investigation for ballot tampering and money laundering, Lee has yet to be linked to any wrongdoing.

He had pledged not to run after being named the caretaker mayor, but changed his mind in August when powerful San Francisco politicians such as former mayors Newsom, Willie Brown, and U.S. Sen. Dianne Feinstein pushed him to reconsider.

Other contenders for the distinction of becoming the city's first Asian-American mayor included Democratic State Sen. Leland Yee, Adachi and Board of Supervisor President David Chiu. None broke out of single-digit percentages, however.

Caleb Ng, a Chinese-American who voted at City Hall, said he didn't cast his ballot based on ethnicity.

"It's not about race; it's about who can best do the job," he said.

Other potential "firsts" in Tuesday's mayoral race were Herrera and Avalos. Either would be the city's first Hispanic mayor. Herrera has championed causes that help make San Francisco a progressive touchstone, including arguing against Proposition 8, the state's same-sex marriage ban. Avalos was a social worker and labor organizer before being elected to the Board of Supervisors.

Candidate Bevan Dufty would become the city's first openly gay mayor. He served on the Board of Supervisors in the same seat once held by slain gay-rights leader Harvey Milk, and his personal story is classic San Francisco: He and a lesbian friend had a child through in-vitro fertilization, a 5-year-old girl often at his side at campaign events.

This is the first mayoral election in which ranked-choice voting adopted in 2002 and designed to save the city an estimated $15 million in runoff costs over 10 years appears ready to kick into gear. Newsom was re-elected in 2007 with more than 70 percent of the vote, eliminating any need to start counting second- and third-choice votes.

If no candidate gets a majority, the last-place candidate is eliminated. Voters who chose that candidate have their votes transferred to their second-choice candidates. If a voter's first and second choices are eliminated, then their third-choice is counted, a process that repeats until one candidate receives more than 50 percent. And it is one that could take several days to tabulate.

Critics of the system say it forces candidates to tone down their views on issues so they don't alienate potential second- and third-place votes from their opponents' supporters.

"I'm not a fan of it," said Alice Engstrom, who dropped off her mail-in ballot at City Hall on Tuesday. "It doesn't really create a distinction between the candidates because everybody is vying for second- and third-place votes."