A San Francisco ballot measure to tax commercial landlords who leave their storefronts vacant prevailed Friday, three days after the polls closed.

Proposition D will hit landlords with a vacancy tax if their storefronts remain unoccupied for more than six months. The measure, which needed a two-thirds majority to pass, was winning 69.62% to 30.38% after Friday’s count, the city’s Elections Department reported.

The numeric totals were 170,723 in favor to 74,495 against. The Elections Department said 29,000 ballots remain to be processed, the vast majority of which are provisional — ballots given to people whose eligibility must be verified before their votes can be counted.

Also winning was Proposition E, which will limit the amount of office space San Francisco can allow each year if the city fails to build enough affordable housing, based on targets set by the state.

The measure, which needed a simple majority to pass, was leading 54.54% to 45.46% — 130,736 to 108,983.

Supervisor Aaron Peskin placed Prop. D on the ballot in an effort to reduce the glut of vacant storefronts dotting San Francisco streets. It would tax the owners of properties left empty for more than 182 days in more than 30 neighborhood commercial areas in the city, including Union Street, West Portal and Haight Street. It would take effect next year.

“I’m thrilled that San Francisco voters saw the wisdom in this tax, which was designed to activate dormant, blighted storefronts in neighborhood commercial corridors across the city and to give small businesses a leg up in negotiating fair rents,” Peskin said in a statement.

“To the small business owners and merchants associations who believed in Proposition D, this is the beginning of a set of reforms that the Board of Supervisors will be undertaking to help small businesses survive and thrive,” Peskin said.

Prop. E was sponsored chiefly by Todco, an organization that operates and advocates for affordable housing in San Francisco, and its executive director, John Elberling.

Jon Jacobo, Todco’s policy director, said in a statement that voters “have shifted the paradigm of San Francisco. They have declared that we prioritize affordable housing before office development, and that is now the new norm in San Francisco.”

One Superior Court judge race remained too close to call Friday. The contest for Seat 21 on the state court’s bench was opened up by the retirement of Judge John Stewart.

Karolulvindar “Rani” Singh, a prosecutor in the district attorney’s office for more than 20 years, had a lead of less than a percentage point over Carolyn Gold, a longtime tenant lawyer and founder of the Eviction Defense Collaborative.

The elections department’s next update will be Saturday at 4 p.m.

Dominic Fracassa is a San Francisco Chronicle staff writer. Email: dfracassa@sfchronicle.com Twitter: @dominicfracassa