A billboard opposing ballot measure F on Oct. 29 in San Francisco. The measure, which would have placed limits on short term rentals in the city by services like Airbnb, was rejected by voters on Tuesday.

On Tuesday, voters in San Francisco rejected a ballot measure that would have put stricter limits on how long people can rent out their homes using short-term rental services such as Airbnb.

In a long-running debate over affordable housing in a city increasingly dominated by workers from Silicon Valley, the measure, Proposition F, was defeated 55 percent to 45 percent.

The controversial proposal pitted one side – which argued services such as Airbnb limit the supply of affordable housing in the city – against those who say such services allow middle class people to make extra income by renting out extra rooms in their houses.

The defeat for Proposition F came after lobbying efforts on both sides, including an $8 million effort by Airbnb to defeat the measure and a rally by housing activists opposed to the measure at the company’s headquarters, which included a brass band.

“Voters stood up for working families’ right to share their homes and opposed an extreme, hotel-industry-backed measure,” Airbnb global policy chief Chris Lehane said in a statement. “San Francisco has experienced affordability issues for decades and our community wants to be part of the solution."

The measure would have capped home-shares at 75 nights per year and required Airbnb and other hosting services such as Craigslist, Flipkey, and HomeAway/VRBO to remove listings that exceeded the limit. It also included additional regulations aimed at cracking down on short-term rentals, which supporters of the measure argued are poorly regulated.

“Losing is always a disappointment,” Dale Carlson, who led the campaign to limit short-term rentals, told the San Francisco Chronicle. But, noting the millions that Airbnb had spent to defeat the proposal, the margin was “still pretty remarkable,” he said.

The measure was backed by a mixture of housing activists, hotel workers’ unions, landlords, and neighborhood groups, the Chronicle reported. They raised about $482,000 to block the measure, mostly from the hotel workers’ union Unite Here.

But the stakes were high for Airbnb — which was founded five years ago in San Francisco.

The company mounted a large-scale campaign, contacting 138,000 city residents who had hosted people or stayed in short-term rentals in the city during the past year to encourage them to vote against the measure. Proposition F was also opposed by San Francisco mayor Ed Lee, who is seen as a friend to the tech industry.

“Strategically, it’s a victory,” Arun Sundararajan, a professor at New York University’s business school who studies the sharing economy, told the Seattle Times. “Here’s a piece of regulation that wasn’t in Airbnb’s best interest and people have voted against it.”