Public interest was "strongly in favour of the navy," the court ruled
The US Supreme Court has removed restrictions on the navy's use of sonar in training exercises near California.
The ruling is a defeat for environmental groups who say the sonar can kill whales and other mammals.
President George W Bush intervened in the long-running dispute, citing national security interests.
In its 5-4 ruling, the Supreme Court said the navy needed to conduct realistic training exercises to respond to potential threats.
The court did not deal with the merits of the claims put forward by the environmental groups.
It said, rather, that federal courts abused their discretion by ordering the navy to limit sonar use in some cases and to turn it off altogether in others.
The dispute involved 14 training exercises off the California coast that began in February 2007 and are scheduled to end in January 2009.
In reinstating the use of sonar, the top US court rejected a lower federal judge's injunction that had required the US Navy to take various precautions during submarine-hunting exercises.
The Bush administration argued that there is little evidence of harm to marine life in more than 40 years of exercises off the California coast.
It said that the judges should have deferred to the judgment of the navy and Mr Bush.
Writing for the majority, Chief Justice John Roberts said overall public interest was "strongly in favour of the navy".
"The most serious possible injury would be harm to an unknown number of the marine mammals," Chief Justice Roberts wrote. "In contrast, forcing the navy to deploy an inadequately trained anti-submarine force jeopardises the safety of the fleet."