In 2013, the new owners of a four-unit Spanish-style building in the Los Angeles neighborhood of Fairfax evicted their tenants. The residents, some of whom had lived there for decades, had been paying between $1,600 and $2,600 a month.

A few weeks later, the same apartments popped up on Airbnb. The landlords were charging around $500 a night.

Practically every major U.S. city is struggling with how to handle the boom of short-term rentals. Most have enacted or are considering regulations for services like Airbnb.

Critics of sites like Airbnb have long claimed that the services remove affordable housing from the market by turning rentable apartments into unofficial year-round hotels. A drop in supply can mean higher rents for remaining apartments. Hotel industry groups are also upset at the loss of revenue.

But Airbnb claims its site primarily offers an "economic lifeline" to help residents pay their bills, rent or a mortgage.

This week, Los Angeles started to take action against rent-controlled apartments that have been illegally converted into short-term rentals The city filed criminal charges against the Farifax building's owners and civil cases against three other building owners. Five of the displaced tenants filed a lawsuit against the owner and Airbnb in December.

The city has also proposed an ordinance that would let hosts rent their homes for up to 120 days a year, as long as they live there at least six months of the year and follow a number of rules.

New York state and San Francisco are also close to cracking down on short-term rental sites with hefty new fines.

A pending New York bill would make it illegal for many people to list their apartments on sites like Airbnb. It's already illegal for people to rent most apartments for fewer than 30 days in the state, but this law backs it up with bite. Hosts violating the ban would face fines up to $7,500. Airbnb says more than 40,000 hosts could be subject to the fines.

"This is a bad proposal that will make it harder for thousands of New Yorkers to pay the bills," Josh Meltzer, Airbnb's head of New York public policy, said in a statement.

Related: Berlin cracks down on Airbnb to keep rents under control

In Airbnb's hometown of San Francisco, a new rule set to take effect on July 27 will require all hosts to register with the city. Instead of fining hosts, the San Francisco law would fine the rental companies up to $1,000 a day for each listing, putting the burden on the companies to make sure each listing is legal.

But the $50 registration process is analog enough to turn off many hosts. It can't be completed online and requires submitting all the documents in person.

Chicago on Wednesday passed an ordinance that will tack a 4% surcharge onto short-term rentals and require hosts to register their units. It also lets some residential neighborhoods petition to have unwanted listings banned.

Other cities like Seattle and New Orleans are still weighing legislative options. They include surcharges, annual caps on rentals, and safety regulations. Airbnb and industry groups are actively talking to most of the cities, hoping to shape any future laws.

Some U.S. locations are friendlier to the industry. San Jose, Rhode Island and Denver have all passed Airbnb-friendly laws. In Philadelphia, people can share homes for up to 180 days a year.

Related: Airbnb restrictions shot down in San Francisco vote

Airbnb is not alone. Local and state governments have been busy trying to crack down on the on-demand industries that already flourished in unregulated gray areas.

Ride-hailing companies Uber and Lyft have teams of lawyers and lobbyists fighting a seemingly unending stream of lawsuits and laws. The companies recently pulled out of Austin, Texas, over background check requirements, claiming fingerprinting would slow down the driver on-boarding process

Airbnb is prepared to fight. It is valued at more than $25 billion, and it has hired political veterans like Chris Lehane, a former adviser to Bill Clinton.

To convince cities and activists that short-term rentals can serve a common good, Airbnb might have to work harder to weed out sketchy landlords like the ones in Los Angeles.

"I think short-term rentals pose a serious threat to affordable housing," said attorney Randy Renick, who represents the Los Angeles tenants. "And in Los Angeles, the platform most widely used by landlords to evade the law is Airbnb."

Updated to include new Chicago Airbnb regulations.