A federal judge formally blocked new rules that would have forced tobacco companies to display graphic images on packs of cigarettes that were designed to shock consumers and deter them from smoking.

The Wednesday ruling, which was presaged by a temporary injunction issued by the same judge in November, strikes a blow to one of the government’s most aggressive efforts to prevent deaths linked to cigarettes.

At issue were regulations published by the Food and Drug Administration last year in response to congressional legislation. The rules required tobacco firms to affix large warning labels to cigarette packages, cartons and advertising. The warnings were to include such images as a bare-chested cadaver and a man exhaling cigarette smoke through a tracheotomy hole.

The Justice Department, which appealed the temporary restraining order, is also expected to appeal Wednesday’s ruling.

Some of the country’s largest cigarette makers, including R. J. Reynolds Tobacco and Lorillard, sued to block the requirements, arguing that they were too broad and violated the companies’ First Amendment rights. The Justice Department, which represented the FDA, countered in court papers that the images were effective in conveying the dangers of cigarette smoking.

The White House called the labels “common sense measures that will help prevent children from smoking.”

U.S. District Judge Richard J. Leon of the District’s federal court initially sided with the tobacco firms in issuing the temporary restraining order that blocked the new rules. In his 19-page Wednesday opinion, Leon reiterated that analysis.

The government may compel companies to issue warnings that convey facts to consumers, Leon wrote, but the new requirements went too far because they were “neither designed to protect the consumer from confusion or deception, nor to increase consumer awareness of smoking risks; rather, they were crafted to evoke a strong emotional response calculated to provoke the viewer to quit or never start smoking.”

“Although an interest in informing or educating the public about the dangers of smoking might be compelling, an interest in simply advocating that the public not purchase a legal product is not,” Leon wrote.

Floyd Abrams, a First Amendment lawyer who represents Lorillard, said the ruling “makes clear that the government cannot compel speech except in very rare circumstances and certainly cannot do so in ones in which it is telling the seller of a lawful product to urge them not to buy it.”

An FDA spokeswoman declined to comment. Matthew L. Myers, president of the Campaign for Tobacco-Free Kids, called the ruling “inconsistent with the scientific evidence, the health effects of smoking and the impact of warning labels.”

Warnings on cigarette packs and in advertising began in 1966, and smoking rates fell steadily for decades. One in five American adults and teens still smokes, however, and smoking kills hundreds of thousands each year.