State Supreme Court Judge Milton Tingling issued the ruling Monday, saying: "The loopholes in this rule effectively defeat the stated purpose of this rule."
The ban was issued by Mayor Michael Bloomberg's office as a method for combating rising obesity rates in the city. Sales of sodas and other high-calorie drinks would have been limited to 16-ounce containers or smaller.
The judge ruled the measure, the first of its kind in the country, would arbitrarily apply to only some beverages and place that sell them. Tingling also said the city Board of Health intruded on the city council's authority in approving the size of the banned containers. The Board of Health approved the measure in September.
The city said it would appeal the ruling as soon as possible.
The city was to begin enforcement of the rule in March, but would delay issuing $200 violations until June.
The Board of Health approved the measure in September in the latest attempt by Bloomberg to improve New Yorkers' eating habits. Previously, City Hall forced chain restaurants to post calorie counts on their menus, barred artificial trans fats in restaurant food and prodded food manufacturers to use less salt.
City officials have called the size limit a pioneering attempt to improve public health. They point to the city's rising obesity rate - about 24 percent of adults, up from 18 percent in 2002 - and to studies tying sugary drinks to weight gain. Care for obesity-related illnesses costs government health programs about $2.8 billion a year in New York City alone, according to city Health Commissioner Dr. Thomas Farley.
Soda makers, restaurateurs, movie theater owners and other business groups sued, arguing among other things that the measure is too limited to have a meaningful effect on New Yorkers' waistlines.
They also complained that it would take a bite out of business for the places that have to comply, while other establishments - supermarkets and some convenience stores, for example - would still get to sell sugary drinks in 2-liter bottles and supersize cups.
Critics also said the restriction should have gone before the elected City Council instead of the Bloomberg-appointed health board.
The Associated Press contributed to this report.