The lawsuit was filed against Eric T. Schneiderman, the state attorney general, Mayor Bill de Blasio and the City of New York.

New York lawmakers, including State Senator Liz Krueger, one of Airbnb’s primary legislative foes, counter that they had the Communications Decency Act in mind when they drafted the bill, which is why it holds the hosts responsible for advertising illegal listings and does not impose any fines on Airbnb.

“This is an issue that was given careful, deliberate consideration, but ultimately these activities are already expressly prohibited by law,” Rich Azzopardi, a spokesman for Mr. Cuomo, said in a statement.

Mr. Schneiderman said in a statement: “Airbnb can’t have it both ways: It must either police illegal activity on its own site, or government will act to protect New Yorkers.” Austin Finan, a spokesman for Mr. de Blasio, said in a statement, “We would apply this tool, just as we do our current ones, to hold bad actors accountable.”

Regulators and affordable housing advocates around the world worry that Airbnb is making it easier to illegally rent out apartment units for short stints to travelers, taking units off the market for full-time residents and driving housing costs higher. Mr. Azzopardi said that illegal rentals “compromise efforts to maintain and promote affordable housing by allowing those units to be used as unregulated hotels.”

Airbnb made several attempts over the past few months to convince Mr. Cuomo to veto the bill, a move that would have rankled Democrats, Republicans and affordable housing advocates. The company commissioned a study to show that voters support Airbnb and it has used a super PAC valued at $11 million to pay for ads explaining where different legislators stand on the short-term rental business.

Since 2010, it has been illegal in New York to rent out a whole apartment for fewer than 30 days. But some tenants and landlords have ignored those rules and have been using Airbnb to rent out their apartments for much shorter periods.