A federal appeals court Thursday blocked a San Francisco city ordinance requiring health warnings on advertisements for soda and other sugary drinks, saying it violated constitutionally protected commercial speech.

The unanimous en banc ruling from the Ninth Circuit Court of Appeals granted a preliminary injunction preventing the law from taking effect and referring the matter back to a lower court.

The required warnings "offend plaintiffs' First Amendment rights by chilling protected speech," the judges wrote, adding that while the city "may be commended for aiming to address serious and growing public health problems," beverage companies were likely to suffer irreparable harm under the law because the warnings would drown out the ads' other visual elements.

VIRAL 'CHICKEN SODA' STAR TRIES PAIRING CHICKEN WITH OTHER STRANGE 'DIPS'

The law passed by San Francisco in 2015 required beverage advertisements within city limits to include warnings that drinking sugary drinks contribute to health problems. The American Beverage Association, which represents Coca-Cola, PepsiCo and others, joined retail and advertising organizations to argue in court that the ordinance should be blocked.

"We are pleased with this ruling, which affirms there are more appropriate ways to help people manage their overall sugar consumption than through mandatory and misleading messages," the beverage association said in a statement. It added that it hopes to work with public health groups in San Francisco on helping residents make informed decisions about their diets.

CLICK HERE TO GET THE FOX NEWS APP

A three-judge panel of the circuit court blocked the law in 2017, but the entire 11-judge panel said last year it would rehear the case.

The law is part of an effort to reduce the consumption of sweet beverages as a way to combat obesity, diabetes, heart disease and tooth decay. Cities in California and across the nation have imposed taxes on sodas and other sugary drinks.

The Associated Press contributed to this report.