The US Navy has been ordered not to use mid-frequency sonar equipment during training exercises off the coast of California until the end of 2009.
Campaigners fear military sonar harms marine mammals
A federal judge ruled in favour of campaigners who argued that the devices harmed marine mammals in the area.
They said noise pollution from sonar disorientated whales, causing them to become stranded on beaches.
A navy spokesman said they would appeal because the injunction jeopardised the nation's safety and security.
The legal action was brought by a coalition of animal welfare groups, led by the Natural Resources Defense Council (NRDC).
"The court's order confirms that during sonar testing and training, the navy can and must protect whales and other marine life in the extraordinarily rich waters off our southern Californian coast," said Joel Reynolds, a senior lawyer for NRDC.
The group, in a statement following the ruling, said the federal judge had recognised that even the Navy's own assessment concluded that the sonar exercises would "cause widespread harm to nearly 30 species of marine mammals, including five species of endangered whales".
US District Judge Florence-Marie Cooper issued the temporary sonar ban following the navy's request to dismiss a lawsuit filed by the NRDC in March, which alleged the widespread use of high-intensity sonar during training exercises breached environmental legislation.
The US Navy's Third Fleet commander, Vice Admiral Samuel Locklear, said they would appeal against the injunction.
"This court decision prevents us from using active sonar," he told the Associated Press. "It potentially puts American lives and our national security at risk."
In a statement, the navy said it already took steps to minimise risks to marine mammals.
It added that it had monitored the waters off southern California for 40 years, and had not seen any whale injuries resulting from the use of sonar equipment.
In 2006, a UK government-commissioned report called for more research into the effects of noise pollution on marine animals.
It concluded that there were many noise sources in the seas, including seismic surveys for oil and gas, shipping, offshore wind farms, military sonar and scientific research.
The study by the Inter-agency Committee on Marine Science and Technology (ICMST) identified 13 cases of strandings by whales and dolphins that appeared to be linked to noise; adding that most of the cases did involve naval vessels.