Some of the most extensive damage and loss of life from recent earthquakes in California have occurred in apartment houses where dwellings sit on top of a ground-level parking garage or a storefront. The shaking undermines the bottom floor, causing the buildings to collapse and in some cases to pancake.

After years of study and debate, San Francisco on Thursday formally adopted a new law requiring owners to retrofit thousands of these so-called wood-frame “soft story” buildings, marking the most sweeping seismic regulations in California in years.

City officials estimate the cost of the retrofitting will be $60,000 to $130,000 per building.Seismologists have long warned that these ubiquitous structures face a particular risk for collapse during a major temblor because the garage must carry the weight of the apartments above. Efforts at mandatory retrofitting, however, have largely failed both at local city councils and the state Legislature because property owners have balked at the costs.

When the Loma Prieta earthquake rocked the Bay Area in 1989, the ground floors of several multi-story apartment buildings crumbled in San Francisco’s Marina district. The shaking sparked fires that devastated neighborhoods.

Five years later, the Northridge earthquake caused the Northridge Meadows apartment building to collapse. Sleeping residents were crushed in their beds, and 16 died.

After Northridge, the Los Angeles City Council discussed mandatory retrofits for soft-story apartments. Hal Bernson, the city councilman who proposed it, said in an interview that property owners fought him “tooth and nail.” In the end, the proposal died.

Some landlords in Los Angeles remain firmly opposed to the type of retrofitting now required in San Francisco. Dan Faller, president and chief executive of the L.A.-based Apartment Owners Assn. of California, said he does not believe the government should force property owners to make upgrades.

“They’re telling businesses how to run their business — after the city has already given approval to the building the way it is and after the owner has purchased the building the way it is. If they want to make a requirement like that, make the city pay for it,” Faller said. “Don’t pass a law that forces me to spend $100,000 on my building.”

Los Angeles City Councilman Mitch Englander applauded San Francisco for its ordinance and said Los Angeles should do the same. But he was skeptical that there was the political support at L.A. City Hall.

“I’d love to see that here in Los Angeles, but I just don’t think it’s a reality,” he said. “From a public safety standpoint, it’s really critical — as we are the epicenter oftentimes of … earthquakes,” he said. "The political will won’t be there, because of the cost. You’ll have landlords and property owners that will oppose it.”

San Francisco officials initially faced similar opposition. City officials and property owners worked for years to hammer out a retrofitting plan.

Ultimately, property owners determined that the retrofitting was worth the cost if it would prevent widespread destruction in the event of a huge temblor. The law ended up being approved by the Board of Supervisors on an 11-0 vote.

“They knew that we have to do this. And we have to make sure it’s mandatory,” San Francisco Mayor Ed Lee told reporters Thursday as he signed the ordinance into law, on the 107th anniversary of the great 1906 earthquake. “In order to be a truly resilient city, we must protect our residents and make sure their homes are safe.”

More than 55,000 San Francisco residents live in these 3,000 wood-frame “soft-story” buildings targeted by the ordinance, and they also house 7,000 businesses and employ 2,000 people, according to the city. Backers of the law warn of a “Katrina-like” effect if a big quake knocked many of the buildings over.

“We will get back up on our feet much faster if the population remains housed,” Supervisor Scott Wiener said. “And frankly, for several decades San Francisco has been negligent in not doing this. We’ve been very slow in moving toward a mandate. We tried a voluntary approach and it did not work.”

San Francisco’s new ordinance applies to wood-frame buildings built before 1978, which are at least three stories tall and have at least five residential units.

Property owners would be given four to seven years to complete the retrofit after they receive a notice from the city asking for an inspection. Those with a shorter time frame are buildings that have a particularly high potential for loss of life, such as those that house a nightclub, seniors or students, or buildings with 15 or more units.

Property owners must pay for the work out of their own pockets or get a loan. But the ordinance says they can fully pass on the costs of the seismic retrofit to their tenants — even those protected by rent control — over a period of 20 years.

The retrofitting typically involves adding new walls or steel braces to keep the ground story strong so it doesn’t crumble when hit with side-to-side motion.

Property owners who refuse to comply with the rules could be taken to court by the city attorney’s office.

Only two other cities in California have passed mandatory retrofit rules for wood-frame soft-story buildings: Santa Monica, which passed its ordinance shortly after the Northridge earthquake in 1994, and the Bay Area suburb of Fremont. A few other cities, including Berkeley, require only a seismic evaluation, and have voluntary retrofitting rules.

San Francisco officials, including former Mayor Gavin Newsom, worked for years to address concerns from both property owners and renters.

One stumbling block was whether banks would lend owners the money to do the upgrades amid the financial crisis. The city worked with community lenders, which agreed to provide loans.

Some property owners said they didn’t want to take out the loans in their names. So the city is setting up a system in which the loans can be provided in the name of the property and paid back with increased property taxes.

The San Francisco Tenants Union only recently endorsed the mandatory measure after receiving assurances from the Board of Supervisors that it would streamline the process for low-income tenants to receive hardship exemptions to rent hikes due to the seismic retrofit.