Champions of housing beat out urban tree advocates as the San Francisco Board of Supervisors unanimously approved a plan to transform the UCSF Laurel Heights campus into a 744-unit housing and retail complex.

Despite protests from many neighbors — who said the project at 3333 California St. is out of scale with the residential enclave and would destroy too many mature trees — the board on Tuesday night backed the project. More than five years in the making, the proposal includes 186 affordable units for seniors, a child care facility, 5 acres of open space and 35,000 square feet of retail.

The project would be one of the largest built in that area of the city, which includes wealthy neighborhoods that have resisted both affordable and market-rate housing in recent decades.

Though opponents can still file a lawsuit over the project, the developer has a secret weapon: The proposal is covered under a state law that would speed up any court challenge to 270 days. The development team, San Francisco-based Prado Group and SKS Partners, hopes to break ground by early 2021, after UCSF, which occupies the hulking office building now on the site, moves its employees to Mission Bay next year.

Before the vote, Supervisor Catherine Stefani, who represents the neighborhood, said that she backed the proposal for its open space, child care center and especially its affordable senior units, which would be built by Mercy Housing. She stressed that the city is “not coming close to meeting the need for affordable senior housing now or into the future.” Only 8% of the city’s affordable housing pipeline is for seniors.

“I knew I wasn’t going to be able to make everybody happy,” she said, adding that she wanted to make sure in her “heart, gut and mind” that the project “would be an incredible addition to an already vibrant community.”

The debate had all the hallmarks of San Francisco development spats. Residents said it would snarl traffic and fuel parking headaches, and its density would feel out of context with the single-family homes across the street. Some feared that the retail could attract a raucous late-night crowd or hurt existing merchants on California Street.

But the trees — which ones would be chopped down and what would replace them — took up the bulk of the discussion Tuesday night. Despite being privately owned, the UCSF campus — a partially walled-off parcel sandwiched between the residential Laurel Street and busy California Street and Presidio and Masonic avenues — has long been treated as an unofficial play space and dog park.

The developers emphasized that the project would be tree-friendly. Though a total of 226 existing trees will be axed, 512 new trees will be planted, including 88 street trees next to the property.

But reassurances didn’t assuage the complaints of tree aficionados. One resident said that even if trees are replaced, “it is still murder.”

Others said that the loss of trees at the transit-oriented housing development would speed up climate change — a claim that Deborah Dwyer, the city’s principal environmental planner, shot down. Dwyer said that the type of transit-oriented housing proposed would more than make up for any lost foliage.

“Emissions from vehicles are far worse contributors to climate change than the loss of the trees,” she said.

As part of the approval process Tuesday, the board heard an appeal by three groups, which included the Laurel Heights Improvement Association. Kathy Devincenzi, who represented the appellants, said that the developers had ignored several community “alternatives” which she said would produce the same amount of housing while preserving the current building and the existing trees. The city and the developer said the community alternatives were not feasible.

Stefani said she took pains to weigh every aspect of the tree controversy, visiting the site to examine those slated to be chopped down and those to be saved. She said she didn’t buy into the tree vs. housing contest.

“I know we can have trees and we can having housing,” she said. “But trees are an emotional topic.”

Prado Group partner Dan Safier, who lives near the site, said the emotions on display at the hearing “reflected the importance of getting a project like this passed in the city, particularly in District Two where there hasn’t been much housing built at all in 50 years.”

“This kind of change is emotional for people, and trees are an emotional issue,” he said. “We feel good about the fact that we are taking a site with a lot of older, unhealthy trees and we are going to end up with a much better urban canopy.”

Plenty of supporters — including local residents, labor representatives and housing advocates — also spoke at the hearing.

“Trees are beautiful and certainly a resource, but this project creates housing, which is a human right, and it is a housing crisis we are facing,” said Nico Nagle of the San Francisco Housing Action Coalition. “The best thing you can do to mitigate the current climate issue is to create dense housing near transit, and this project does that.”

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