Millions of shots have been given and hundreds of service members have been punished for refusing them since the mandatory vaccinations started in 1998.
The judge ruled that the anthrax vaccinations fell under a 1998 law prohibiting the use of certain experimental drugs unless people being given the drug consent or the president waives the consent requirement.
Congress passed the law following fears that the use of such drugs may have led to unexplained illnesses among veterans of the 1991 Persian Gulf War that have come to be known as Gulf War Syndrome.
"The women and men of our armed forces put their lives on the line every day to preserve and safeguard the freedoms that all Americans cherish and enjoy," said Judge Emmet G. Sullivan of the United States District Court in Washington.
Sullivan issued a preliminary injunction, saying, "The United States cannot demand that members of the armed forces also serve as guinea pigs for experimental drugs."
The injunction is the result of a class action law suit brought by military personnel and civilians working for the Pentagon, reported CBS News Correspondent Howard Arenstein.
In his ruling, Sullivan pointed to the apparent risk in receiving the anthrax vaccination, noting that the rate of adverse reaction was recently revised upward from 0.2 percent to between 5 percent and 35 percent. Six deaths are attributed to the vaccine, Sullivan said.
The Pentagon had no immediate comment. A Pentagon Web site promoting the vaccine claims that data going back 20 years demonstrates the vaccine is safe, and that there is no evidence the vaccine is connected with illness suffered by Gulf War veterans.
Sullivan rejected the government concern that military discipline would be harmed if courts intervene between soldiers and their military superiors.
Believing Iraq and other nations had produced anthrax weapons, former Secretary of Defense William Cohen in 1997 ordered the armed forces immunized.
Shots started in 1998 for soldiers in areas believed to present the highest risk of infection — the Persian Gulf, then Korea.
Anthrax is caused by bacteria spores spread either by animals or weapons. The most serious form affects the lungs, with fatality rates near 50 percent. Death is somewhat less likely in cases where anthrax infects the digestive tract, and is rare when the skin is infected.