A ballot measure to give tenants facing eviction lawsuits the right to taxpayer-funded legal representation won Tuesday.

With 99 percent of precincts counted, Proposition F, “Defend SF Against Evictions,” won with nearly 56 percent in favor, and 44 percent opposed.

Takeaway: Tenants’ rights groups that back the measure have been fighting to keep renters in their homes during the tech boom, which since 2010 has resulted in a steady increase in evictions. Roughly 1,600 tenants were evicted last year, about a 26 percent increase over 2010. The city spends about $2 million a year to provide legal help to some low-income people, but only about half of those receiving an eviction notice are represented by an attorney. The expanded legal services is estimated to cost the city $5.6 million a year if approved.

Background: The Prop. F campaign was organized by the San Francisco chapter of the Democratic Socialists of America. Proponents argued that providing legal counsel to more tenants facing eviction could prevent an increase in homelessness, which costs taxpayers far more than would be spent on providing legal services to those tenants.

Advocates for Prop. F raised more than $190,000. Among them were tenant rights attorney Dean Preston, who ran for the Board of Supervisors in 2016 and spent $28,000 on the proposition, and Facebook engineer Jason Prado, who contributed $20,425. Other contributors included attorney and former Supervisor Matt Gonzalez, City College Trustee Tom Temprano, and affordable housing advocate Peter Cohen.

Preston earlier said he was “cautiously optimistic” Prop. F would win.

Now Playing: Now Playing California primary: Live election analysis San Francisco Chronicle

Chronicle Live with Christine Pelosi San Francisco Chronicle

Election night with former SF Mayor Willie Brown San Francisco Chronicle

Chronicle Live with SF Mayor Mark Farrell San Francisco Chronicle

SF mayoral candidate Angela Alioto San Francisco Chronicle

Jane Kim mayoral candidate SFChronicle

SF mayor candidate Mark Leno on his favorite place in the city San Francisco Chronicle

Candidate for California Governor Gavin Newsom FoxLA

Meet the 4 leading candidates for California lt. governor KCRA

SF mayoral candidate Angela Alioto's favorite place SFChronicle

SF mayoral candidate London Breed SFChronicle

“If Prop. F passes, and it’s trending in the right direction, it will do more to stop evictions in San Francisco than any measure passed in the city since voters approved rent control,” he said.

The San Francisco Apartment Association opposed the measure but didn’t run an active campaign until right before election day. No campaign finance data for the anti-F campaign was immediately available. Opponents object to the fact that the measure applies to renters of all income levels, including the wealthy, without means testing to determine if the person getting evicted is in need of free legal assistance.

J.K. Dineen is a San Francisco Chronicle staff writer. Email: jdineen@sfchronicle.com Twitter: @SFjkdineen