A San Francisco law protecting school employees, families with children and child care center workers from evictions during the school year survived a legal challenge Wednesday when the state Supreme Court denied an appeal by real estate groups.

The ordinance, approved unanimously by the Board of Supervisors, took effect in April 2016. It expanded a 2010 ordinance that protected families with children under 18 from evictions during the school year by owners who wanted to occupy the property. The law also requires landlords to wait until summer before evicting those families to remodel the property, convert it to a condominium or demolish it, and extends the same protections to teachers and staff members at schools and child care centers.

Supporters of the measure said most teachers and other school employees could no longer afford to live in San Francisco. A Chronicle analysis in 2016 found that a teacher with an income of $65,240 a year, the district average, would have to pay nearly two-thirds of that salary for a one-bedroom apartment in the city at the median rent of $3,500 a month.

The ordinance was in effect for less than five months before Superior Court Judge Ronald Quidachay overturned it, saying state law barred local governments from limiting the grounds for eviction. The First District Court of Appeal in San Francisco disagreed in February.

“The purpose of the ordinance is to protect children from the disruptive impact of moving during the school year or losing a relationship with a school employee who moves during the school year,” Justice Mark Simons said in the appeals court’s 3-0 ruling. He said the ordinance is “a permissible limitation upon the landlord’s property rights” because it gives certain groups of tenants protection from eviction during a specific period and does not restrict the overall right to evict under state law.

The San Francisco Apartment Association and the Small Property Owners of San Francisco Institute, the organizations that challenged the ordinance, asked the state’s high court to review and reverse the appellate ruling. The court unanimously denied review Wednesday, allowing the city to enforce the ordinance and leaving the ruling intact as a binding precedent for trial courts statewide.

Andrew Zacks, a lawyer for the real estate groups, said the decision was disappointing and would “probably spawn further onerous regulations” in San Francisco and elsewhere.

A city should not have the power to decide “the timing of the ability to recover possession of your property,” Zacks said.

City Attorney Dennis Herrera said the court upheld “protections that give teachers and families with schoolchildren a fighting chance to stay in their city.”

The case is San Francisco Apartment Association vs. San Francisco, S247750.

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter: @BobEgelko