SAN FRANCISCO — In a surprising reversal expected to be felt nationwide, Airbnb has extended an olive branch to San Francisco lawmakers and agreed to help the city enforce its home-sharing rules, including limiting the days an Airbnb landlord can rent out a home.

The move signals a significant shift in a battle between a company that has upended rental markets and San Francisco, one of the nation’s most expensive cities. Airbnb says its short-term rentals help property owners make ends meet, but lawmakers worry that without regulations the practice may drive up the cost of housing.

Airbnb on Sunday said it’s willing to cooperate with city officials to make sure landlords listing their homes with the service register with the city and comply with its 90-day short-term rental cap. It’s a major policy shift for the $30 billion company, which has spent months locked in contentious battles with San Francisco and other cities over their short-term rental laws — even taking them to court.

“There’s a clear path forward to fix our short-term rental rules that protects housing and neighborhood quality of life in San Francisco,” Chris Lehane, global head of policy and public affairs at Airbnb, wrote in an opinion piece published in the San Francisco Chronicle. “We recognize the work we need to do and we are eager to be a better partner with the city in the years to come.”

The San Francisco move is part of a larger effort by Airbnb to cooperate with city officials, and the company hopes to extend the initiative across the country, said Airbnb spokesman Christopher Nulty. Airbnb, which has more than 2 million short-term rental listings worldwide, already is working on a similar agreement with Chicago and has proposed another in New York City.

As Airbnb has exploded in popularity since it was founded in 2008, it has faced backlash from activists who argue the home-sharing site has contributed to cities’ affordable housing shortages and from lawmakers struggling to regulate the burgeoning industry. But Airbnb counters the platform helps many property owners afford to live in expensive cities such as San Francisco.

In San Francisco, Airbnb proposed a streamlined system that would allow landlords to obtain a city-issued short-term rental registration directly from the Airbnb platform. The idea is to eliminate the lengthy process that requires multiple steps and in-person visits to city offices — and has resulted in just 20 percent of landlords bothering to register.

As part of that agreement, Airbnb would provide the city with data on its landlords, including their addresses, contact information and how many nights they rent their homes. Airbnb also said it’s willing to consider kicking landlords off the platform if they attempt to rent their entire homes for more than the 90 days per year that the city allows.

Airbnb previously had taken a hard-line stance against helping cities with enforcement, and has sued a handful — including San Francisco and New York — when officials tried to force the company to monitor its site for listings that violate city laws. Now those cities probably are watching developments in San Francisco, said Joshua Davis, associate dean for academic affairs at the University of San Francisco School of Law.

“I certainly think that other places where there are similar battles going on, the cities are going to take note,” Davis said. “(Airbnb) knows it’s signaling not only to San Francisco, but possibly elsewhere, that it’s willing to come to some sort of negotiated resolution like this.”

The about-face comes as the Board of Supervisors is set on Tuesday to consider new, stricter short-term rental restrictions that would further reduce the number of days that landlords could rent their entire homes, from 90 to 60.

Last week Airbnb faced a major setback in its lawsuit against San Francisco. A federal judge rejected the home-sharing company’s initial attempt to quash part of the city’s short-term rental law — a section that would subject Airbnb to fines if it booked stays for properties that were listed illegally.

For now, Airbnb says it’s not backing down from that lawsuit. While the company may have offered to help San Francisco with some aspects of its enforcement, it still objects to being forced to do that policing.

The city applauded Airbnb’s announcement, but didn’t seem ready to let the home-sharing company out of the doghouse once and for all.

“We are certainly encouraged that Airbnb appears to be taking steps to meet their requirements under the law,” said John Cote, spokesman for the City Attorney’s Office.

Airbnb recently made another concession to the city. Last month the company announced that starting Nov. 1, Airbnb would not allow San Francisco residents to list more than one property on the home-sharing site. The move was intended to appease activists who argue that Airbnb is exacerbating the city’s affordable housing crisis by allowing professional landlords to turn their buildings into short-term rentals.

Airbnb host Alex Nigg, who rents his San Francisco home when he’s out of town, was encouraged by Airbnb’s newfound willingness to work with the city. Opening that line of dialog could result in some much-needed stability for Airbnb hosts, said Nigg, who also founded Properly, a startup that helps Airbnb hosts schedule cleanings between rentals.

“The challenge for the home-sharing community has been we’ve been in this prolonged legal limbo,” he said. “And I think that’s hurt both sides.”