The Federal Constitutional Court said clauses of laws in the city-state of Berlin and the southwestern region in Baden-Wuerttemberg were unconstitutional because they threatened the livelihood of owners of small bars and clubs.
The six-to-two ruling means that customers in one-room bars and discotheques in the two states can keep lighting up until at least the end of 2009.
It could also send similar legislation in 12 of Germany's 14 other states back to the drawing board.
Lighting up in small establishments in the two states had been effectively outlawed because a separate, closed-off smoking room was required even in the smallest taverns. In Baden-Wuerttemberg, smoking in nightclubs was barred entirely.
The plaintiffs said they faced discrimination in their business practices under the laws.
The court agreed and said the states would have until 2010 to decide whether to introduce a blanket smoking ban, as is the case in the southern state of Bavaria, or one that allows fair exceptions for single-room bars and clubs.
Chief justice Hans-Juergen Papier made clear, however, that the court saw public health as more important than the right to smoke or run a bar and would rule accordingly in any further challenges to the laws.
"A general smoking ban in restaurants and taverns would have more protection under the constitution than the right to practise one's profession as a barkeeper or the freedom to smoke," he said.
In the meantime, the establishments in the two states could go back to their old practices, the judges said, but with certain limitations.
The court said one-room bars where smoking would provisionally be allowed had to be smaller than 75 square metres (807 square feet), offer no food, and not accept anyone under the age of 18 as a patron.
The judges noted that because the number of smokers in such establishments was relatively high, a tobacco ban to protect non-smokers from second-hand smoke "made little sense".
Lighting up in bars and restaurants became largely illegal in the last of Germany's 16 states on July 1, spelling the end of the country's status as one of Europe's last havens for smokers.
The new anti-tobacco laws have met with strong popular resistance and are being challenged by restaurant and pub owners in courts around the country, where nearly one in three adults smoke.
In Saxony, Schleswig-Holstein and Rhineland-Palatinate, judges have lifted the ban in single-room bars, provided the owners serve the drinks themselves.
Meanwhile a report released Wednesday showed that the smoking ban and inflation had led to Germans drinking less beer, the tradition-steeped national drink.
In the first half of 2008, Germans imbibed 52 million hectolitres (1.1 billion gallons), 1.7 percent less than the year before, the federal statistics office said.