City Attorney Dennis Herrera, at podium, talks about a settlement agreement on short term rentals during a news conference Monday, May 1, 2017, at City Hall in San Francisco. (AP Photo/Eric Risberg)

Home-sharing company Airbnb cleared a major legal hurdle in its hometown of San Francisco on Monday, settling a case that was viewed by many in Silicon Valley as a bellwether for how far start-ups can go to test government.

The legal settlement with the city over unregistered listings marks the end of a multiyear battle that pit affordable housing advocates and some local officials against home-sharing start-ups and the wider tech community. Ultimately, Airbnb and its co-defendant, HomeAway, conceded to many of the city’s demands, but also showed other start-ups that there is a payoff to flexing some legal muscle and going up against regulators.

Under the settlement, Airbnb agreed to build software that would automatically send the city the names and address of hosts who sign up locally. People who are already hosts have 8 months to register.

“While we’re happy to see a homegrown San Francisco company like Airbnb succeed, it can’t be at the expense of residents being evicted or units being removed from the housing market so people can make more money putting apartments on Airbnb,” said San Francisco City Attorney Dennis Herrera in a news release.

Currently just 2,100 short-term hosts are registered in San Francisco. Airbnb has more than 8,000 listings, according to Herrera.

Nine years after its founding, Airbnb has become a juggernaut powerful enough to threaten the U.S. hotel industry. But a series of intractable battles with regulators in cities across the world has threatened the $31 billion company’s rise — and its ability to go public.

It took a while for regulators to catch on though. San Francisco didn’t enact laws addressing home-sharing until 2015, when the city legalized renting out one’s home on a short-term basis. The laws required hosts to register with the city and banned individuals from renting out multiple homes or renting their home for more than 90-days a year. Affordable housing advocates and officials say that turning homes into vacation rentals for most of the year cuts down on the housing supply that is available to locals and pushes up prices.

But very few Airbnb hosts have actually registered, causing the city to clamp down further. The ordinance would have fined the short-term rental companies up to $1,000 per day for each illegal listing, along with additional criminal penalties for arranging bookings that flouted the city’s registration system. In June last year, Airbnb sued to block the law.

Airbnb and HomeAway argued that the San Francisco rules violated the First Amendment and the Communications Decency Act, a 20-year-old statute that is considered a pillar of the Web economy. The Act says Internet platforms cannot be held responsible for the illegal activity of third parties that use them to do business. For example, Google is not liable for child pornography posted by advertisers using its software. The San Francisco case raised questions about whether Airbnb’s role as a platform made it more similar to Google’s ad business, per se, than to other platform-like companies such as credit card processors, which can be held responsible if fraudsters use their technology to launder money. Those questions have implications for many Silicon Valley businesses, from eBay to car-sharing apps.

Airbnb has also argued, in San Francisco and in other cities, that sharing information about its hosts would violate their privacy. Critics countered that Airbnb was defending hosts that break local laws to protect its bottom line.

Many of those higher-level questions weren’t decided in the settlement, which established a registration system that both parties could agree upon and set up conditions under which Airbnb would agree to drop its lawsuit.

“While the city's laws were well-intentioned, it did include an onerous registration system. And while we've certainly had issues with the city at various points along the way, we are very appreciative of the San Francisco city attorneys office for this settlement. All the parties really rolled up their sleeves,” said Airbnb's head of global policy Chris Lehane.

“We really want to be able to move on and talk about other things — be able to move forward.”

But lessons can still be drawn from the complicated dance that large start-ups like Airbnb and Uber have engaged in with regulators.

Going into the lawsuit, Airbnb was likely to be well-aware that it had a strong bargaining chip: the city would have a hard time enforcing its registration laws without the company’s help. How, in practical terms, could a handful of city officials, spending their days combing through thousands of listings on Airbnb, actually detect lawbreaking homeowners?

A win may have set a legal precedent, but it may not have helped San Francisco accomplish its actual goal of identifying lawbreaking hosts.

At the same time, and despite all appearances, Airbnb doesn't ultimately want to be at odds with cities. Legal battles can spook investors, customers, and hosts. The company's policy team, led by former Bill Clinton aide Lehane, relishes a fight as much as anyone, but he knows the company benefits more from dealmaking.

That is why Airbnb has built similar registration systems in other cities, such as Chicago and New Orleans. Those other deals, which also involve Airbnb collecting local taxes, were also the result of protracted negotiations. They did not end in lawsuits, which Lehane calls a last resort.

If these concessions have damaged Airbnb's business, the company isn't disclosing it, and it's too early for outsiders to tell. But they have arguably helped the company gain something more important in the near term: legitimacy and a green light to operate.