NEW YORK — The New York City initiative to ban large sugary beverages from restaurants and various public venues has been declared invalid after New York State Supreme Court Justice Milton Tingling issued a ruling.

“The rule is … fraught with arbitrary and capricious consequences,” Judge Tingling ruled. “The simple reading of the rule leads to the … uneven enforcement even within a particular city block, much less the city as a whole. Furthermore … the loopholes in this rule effectively defeat the stated purpose of the rule. It is arbitrary and capricious because it applies to some but not all food establishments in the city, it excludes other beverages that have significantly higher concentrations of sugar sweeteners and/or calories on suspect grounds, and the loopholes inherent in the rule, including but not limited to no limitations on refills, defeat and/or serve to gut the purpose of the rule.”

The ruling came one day before the ban was scheduled to take effect. In his ruling, Judge Tingling also expressed concern for the level of power enacting such a measure would give the New York Board of Health and related agencies.

The ban, which originated from New York City Mayor Michael Bloomberg, sought to limit various food service establishments from offering sugary drinks in containers of more than 16-oz. These establishments were to include restaurants, food carts, delis, movie theater concessions, stadiums and arenas. The rule was not going to affect beverages that contain at least 50% milk, or fruit or vegetable juices that contain no added sugar.

“This is a great victory, particularly for thousands of restaurant operators and industry suppliers serving New York City who would have experienced financial hardships had the ban been enacted,” said Dawn Sweeney, president and chief executive officer of the National Restaurant Association. “We are extremely pleased that the judge recognized that the Board of Health exceeded its authority when it initially passed the ban.”

The National Restaurant Association, the American Beverage Association and others filed a lawsuit several months ago saying the ban was arbitrary and subjected restaurateurs to a standard not required of many of its competitors, including grocery stories and convenience stories.

The A.B.A. responded to the ruling saying, “The court ruling provides a sigh of relief to New Yorkers and thousands of small businesses in New York City that would have been harmed by this arbitrary and unpopular ban. With this ruling behind us, we look forward to collaborating with city leaders on solutions that will have a meaningful and lasting impact on the people of New York City.”

Immediately after the ruling was issued, Mr. Bloomberg responded by saying he would appeal.

“We strongly believe that, in the end, the courts will recognize the Board of Health’s authority to regulate the sale of beverages that have virtually no nutritional value and which, consumed in large quantities, are leading to disease and death for thousands of people each year.

“There are many, many instances where a lower court decision has gone against us and then been reversed…We’re confident that today’s decision will ultimately be reversed.”