A judge struck down New York’s limits on large sugary drinks on Monday, one day before they were to take effect, in a significant blow to one of the most ambitious and divisive initiatives of Mayor Michael R. Bloomberg’s tenure.

In an unusually critical opinion, Justice Milton A. Tingling of State Supreme Court in Manhattan called the limits “arbitrary and capricious,” echoing the complaints of city business owners and consumers who had deemed the rules unworkable and unenforceable, with confusing loopholes and voluminous exemptions.

The decision comes at a sensitive time for Mr. Bloomberg, who is determined to burnish his legacy as he enters the final months of his career in City Hall, and his administration seemed caught off guard by the decision. Before the judge ruled, the mayor had called for the soda limits to be adopted by cities around the globe; he now faces the possibility that one of his most cherished endeavors will not come to fruition before he leaves office, if ever.

The mayor’s plan, which he pitched as a novel effort to combat obesity, aroused worldwide curiosity and debate — and the ire of the American soft-drink industry, which undertook a multimillion-dollar campaign to block it, flying banners from airplanes over Coney Island, plastering subway stations with advertisements and filing the lawsuit that led to the ruling.