Jacob Tugendrajch, a spokesman for Mr. Johnson, called the law a “vital protection against illegal hotels” and said the Council would continue “the fight for this common sense, data-driven law.”

Mr. de Blasio has contrasted home-sharing services with the hotel industry, which is subject to inspections and regulations that allow the city to hold owners accountable. He has argued that Airbnb should also be required to turn over information that helps the city protect the public interest.

An influential union for hotel workers, the Hotel Trades Council, strongly backed the law.

In a 52-page ruling, Judge Engelmayer did not rule on the merits of Airbnb and HomeAway’s claims, but said the injunction would block the law from taking effect pending resolution of the litigation, which he said would proceed expeditiously.

The law would require online rental services to disclose the addresses of its listings and the identities of its hosts to the city’s Office of Special Enforcement on a monthly basis. Hosts would also be required to list whether the dwelling is their primary residence and whether the entire unit or a portion is available for short-term rentals. Companies that failed to share the data would be subject to fines of $1,500 for each listing they did not disclose.

New York City is Airbnb’s largest domestic market, with more than 50,000 apartment rental listings. But under state law, it is illegal in most buildings for an apartment to be rented out for less than 30 days unless the permanent tenant is residing in the apartment at the same time.

City officials hoped the new disclosure requirements would make it much easier for the city to enforce the state law and would lead to thousands of units rented through Airbnb in the city coming off the market.

Airbnb and other home-rental services have been battling regulation nationally and abroad, as cities including Seattle, San Francisco and London have required such companies to share some data through a registration system for listings.