New York Gov. Andrew Cuomo on Friday signed into law one of the nation’s toughest measures targeting short-term apartment rentals, a blow to fast-growing startup Airbnb Inc. in a crucial market.

Airbnb responded to the law, which takes effect immediately, by filing a lawsuit against the state. Airbnb has argued it can’t be held responsible for the content that hosts place on its website. “We will continue to fight for a smart policy solution that works for the people, not the powerful,” Josh Meltzer, head of New York public...