SAN FRANCISCO — Airbnb has charmed and strong-armed lawmakers around the world to allow it to operate in their communities. But two cities, Airbnb’s hometown, San Francisco, and New York, the service’s largest United States market, have not been so compliant.

On Monday, Airbnb sued San Francisco over a unanimous decision on June 7 by the city’s Board of Supervisors to fine the company $1,000 a day for every unregistered host on its service. If Airbnb does not comply, it could face misdemeanor charges.

The suit follows a bipartisan move by New York lawmakers who voted this month to heavily fine anyone who uses Airbnb to rent a whole apartment for fewer than 30 days, a practice that has been illegal in the state since 2010.

The actions show how Airbnb, despite aggressive lobbying efforts, has not been able to persuade some local legislators to play ball. And in the case of New York, the company has demonstrated a surprisingly tin ear for local politics.