San Francisco’s latest attempt to make landlords pay relocation costs for tenants they evict when the property owners go out of the rental business has hit another judicial roadblock.

The ordinance, scaled down from a previous measure, would require landlords to pay displaced tenants the difference between their current rent and the market rate for a similar unit in the city for two years, up to a maximum of $50,000. Tenants would have to show they were using the funds solely for relocation costs and rents, and landlords who faced hardships could appeal to the city Rent Board to reduce their payments.

But Superior Court Judge Ronald Quidachay said the required payments exceed the “reasonable” relocation assistance authorized by the Ellis Act, the state law that allows landlords to evict all their tenants when they leave the rental business without having to show any other grounds for an eviction.

Reasonable payments are those that would offset the immediate costs of eviction — first and last months’ rent, the tenant’s security deposit and moving expenses, Quidachay said in his ruling Friday. He said additional charges to “subsidize the payment of rent that a displaced tenant will face on the open market, regardless of income ... have no relationship to the adverse impact caused by the landlord’s decision to exit the rental market.”

He also noted that the $50,000 maximum payment for two years is more than three times the current payment for displaced San Francisco tenants — $4,500 a year, adjusted annually for inflation — authorized by a 2005 city ordinance that was upheld by the courts.

The ruling is “a major victory for San Francisco property owners,” said Andrew Zacks, a lawyer for three landlords and the Small Property Owners of San Francisco Institute, who challenged the ordinance. “No matter how many times it tries, the city cannot disregard state law.”

The city plans to appeal.

The issue in the case is, “Can we make landlords compensate tenants for what we know are the real impacts of Ellis Act evictions,” Deputy City Attorney Christine Van Aken said Tuesday.

She said the state law allows local governments to “require mitigation of any adverse impact” on evicted tenants. “We think having to pay dramatically new, higher rents is an adverse impact of the eviction,” Van Aken said.

The author of the ordinance, Supervisor David Campos, said he was confident that the law would be upheld on appeal. “I think that in the midst of the worst housing crisis in the history of San Francisco, adjusting relocation payments to reflect the crisis in which we are is a reasonable step,” he said.

An earlier Campos ordinance, which took effect in June 2014, required the same two-year rent subsidy but without the $50,000 limit, and did not require tenants to show that they used the funds solely for housing.

U.S. District Judge Charles Breyer declared the measure unconstitutional in October 2014, saying it violated property rights by forcing owners to pay for problems they didn’t cause — the skyrocketing prices of rental housing, and the gap between market rates and the city’s rent-control law. Quidachay, in a separate case, ruled later that the ordinance also conflicted with the Ellis Act’s authorization of only “reasonable” relocation assistance. The city has appealed both rulings.

City supervisors approved Campos’ new ordinance in May and it was scheduled to take effect in June but has been on hold during the legal challenge.