The ban enacted by the city’s Board of Health last year applied to both bottled and fountain drinks sold at city restaurants, movie theaters, sports venues and street carts.

It did not include grocery or convenience stores that don’t serve prepared food and did not apply to diet soda, other calorie-free drinks or anything that has at least 50 percent milk or milk substitute.

In his ruling against the ban in March, Manhattan Supreme Court Judge Milton Tingling said the restrictions were both “capricious” and “arbitrary” because they only applied to some sugary drinks and certain places that sell them.

“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,” Tingling wrote in the 36-page ruling. “The loopholes in this rule effectively defeat the stated purpose.”

In addition, the judge said the Board of Health encroached on the authority of the City Council when the ban was imposed last year.

“It was decided in the lower court that the Board of Health overstepped its authority by trying to issue new policy. We feel that Justice Tingling’s decision was strong and we’re confident in the ruling. While we commend the city for its commitment to health and wellness, the ban would have arbitrarily and disproportionately penalized small businesses. This is not the way to address the complex issue of obesity.”

Mayor Michael Bloomberg has argued the ban was well within the Board of Health’s jurisdiction and was needed to improve the health of New Yorkers.

“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 every year,” Bloomberg said back in March.

Last week, the health department launched TV and bus ads that said sugary drinks can lead to obesity and other health problems. The city is also launching a radio ad campaign about the risks of diabetes.