Screenshot by Dara Kerr/CNET

San Francisco Mayor Ed Lee signed on the dotted line on Monday and officially legalized peer-to-peer home sharing in the city -- a practice that is touted through websites like Airbnb.

"Now, San Franciscans who just want to share their home with occasional visitors will have a clear set of rules and restrictions to earn extra money to make ends meet," Lee said in a statement.

San Francisco is one of the first cities in the world to make short-term rentals legal -- but, it's been a long road. Legislators have held countless meetings and forums over the past two years to hammer out the bill, which has faced opposition from a range of players, including hotel owners, affordable housing advocates and landlords. Airbnb still faces obstacles and roadblocks from lawmakers in other cities that haven't been as receptive to their business.

New York, for example, has continuously battled with Airbnb over the last year. The state's Attorney General Eric Schneiderman subpoenaed the company for data on its users last October, publicly claiming the service facilitates "bad actors" who rent out dozens of apartments to make a quick buck. Earlier this month, he released a report that said 72 percent of past Airbnb users "appeared to violate" state and local laws.

Airbnb is a service that lets people sublet their rooms or entire homes to strangers. In return for this service, Airbnb gets a cut of the rental -- typically between 9 and 15 percent. The service says more than 4 million people have stayed in Airbnb rentals over the last five years and it's currently in 192 countries. The venture-backed company now has the world's second highest valuation of more than $10 billion, after ride-sharing service Uber.

To legalize Airbnb, San Francisco had to amend its city-wide zoning laws to allow for short-term rentals. Under the old law, temporary rentals were seen as a commercial business and therefore not allowed in neighborhoods or buildings zoned for residential use.

"The fundamental nature of the new law -- one that legalizes home sharing for the vast majority of our San Francisco hosts, those who simply rent out their own home on an occasional basis -- is a huge step forward in San Francisco," Airbnb head of public policy David Hantman wrote in a blog post Monday. "Policymakers are looking at old rules -- some of which were drafted before the Internet even existed -- and enacting some commonsense regulations for home sharing."

While a win for home-sharing companies, San Francisco's new legalization push has its limits. People can only rent their rooms or homes for up to 90 days per calendar year. One exception, however, are hosts who are present during the rental period -- they can lease rooms year round. All people who rent their home on Airbnb also must sign up in a city registry, collect transient occupancy taxes and carry liability insurance. San Francisco's Board of Supervisors voted to pass the bill last week.

"We know the status quo is simply not working," Board President and chief sponsor of the legislation David Chiu said in a statement Monday. "I'm proud to have taken on this tough policy challenge. We delivered a balanced solution that protects our housing from hotel conversion while allowing some flexibility for residents to help them afford to stay in their homes."

While housing advocates agree that a law needs to be in place, many believe this legislation is too soft and doesn't do enough to protect affordable housing, landlords and buildings zoned for residential use.

"We need to enforce the laws that are currently in the books," Janan New, executive director of the San Francisco Apartment Association, which represents landlords, said in August. "If they change the rent law, they need to understand that impacts the whole rental system."

US Senator Dianne Feinstein, and former San Francisco mayor, has also voiced skepticism about legalizing short-term rentals. The senator penned an opinion piece against the new San Francisco law last week saying it was "shortsighted" and could "destroy the integrity of zoning throughout San Francisco." Feinstein's office did not respond to request for comment now that Lee has signed the law.

The fact that legalizing short-term rentals has generated backlash from such a diverse group of people, shows Airbnb has its work cut out for it as it pushes for legislation in other cities. But now, with Lee's endorsement in San Francisco, the first domino has fallen and a road map is in place.

"As the birthplace of the emerging, more sustainable sharing economy, San Francisco must be at the forefront of nurturing and regulating its growth by modernizing our laws and confronting emerging policy issues and concerns," Lee said Monday. "With this balanced, responsible ordinance in place, San Francisco residents can share their homes and we can enforce against bad actors to protect the public and collect taxes on this new activity."