A New York state judge called the planned restrictions on large sugary drinks "arbitrary and capricious."
"The court finds that the regulation ... is laden with exceptions based on economic and political concerns," Justice Milton Tingling wrote.
Mayor Michael Bloomberg quickly vowed to appeal the decision, countering that the city's health department has the legal authority to use the ban to fight an obesity epidemic.
"We believe that the judge's decision was clearly in error and that we will prevail on appeal," Bloomberg told reporters.
Scheduled to begin at midnight, the law would have restricted the sale of sugary drinks to no more than 16 ounces in restaurants, fast-food eateries, movie theaters and stadiums.
But the law would have exempted a variety of retailers, including 7-Eleven, seller of the iconic "Big Gulp" drinks, because it is regulated by the state, not the city.
"The effect would be a person is unable to buy a drink larger than 16 ounces at one establishment but may be able to buy it at another establishment that may be located right next door," Tingling wrote.
The lawsuit was brought by a group of business associations -- including the American Beverage Association, the National Association of Theatre Owners of New York State and the New York Korean-American Grocers Association.
The opponents argued that the city had overstepped its authority. Among other things, they said, the rules would disproportionately hurt small and minority-owned businesses.
"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," the American Beverage Association said in a statement.
The super-sized drinks ban is just the latest in a series of Bloomberg administration regulations targeted at public health, including banning trans fats and the required posting of calorie counts.
Nearly 60% of New York City adults and 40% of city schoolchildren are overweight or obese, according to the decision.
"Being the first to do something is never easy," Bloomberg said. "When we began this process we knew we would face law suits."
Critics have decried the rules as a sign of the growing "nanny-state" and an unfair intrusion on personal freedom.
In a statement, the National Association of Theatre Owners said the ban had been "all about power" and lauded the rejection of an attempt to "unilaterally tell New Yorkers what to drink and where to drink it."
On the streets of New York, Colin Lively said that he had just had a Big Gulp.
"I don't care how much soda people drink, there are bigger issues in this city than people drinking sugar, having more than two sugars in their coffee," he said. "I mean, look around us. Isn't there more that our mayor can concentrate on than sugar?"
|Inside the underground sex economy|
|NJ agrees to ban Tesla direct sales|
|West prepares sanctions against Russia over Ukraine|
|Five predictions for the World Wide Web that were way, way, way off|
|The Deep Web you don't know about|