A federal appeals court ruled on Friday that the US Navy was wrongly allowed to use sonar in the nation’s oceans that could harm whales and other marine life.

The ninth circuit court of appeals reversed a lower court decision upholding approval granted in 2012 for the Navy to use low-frequency sonar for training, testing and routine operations.

The five-year approval covered peacetime operations in the Pacific, Atlantic and Indian Oceans and the Mediterranean Sea.

The appellate panel sent the matter back to the lower court for further proceedings.

A message seeking comment from representatives of the US Pacific Fleet in Honolulu was not immediately returned.

Sonar, used to detect submarines, can injure whales, seals, dolphins and walruses and disrupt their feeding and mating.

The 2012 rules adopted by the National Marine Fisheries Service permitted Navy sonar use to affect about 30 whales and two dozen pinnipeds; marine mammals with front and rear flippers such as seals and sea lions, each year.

The Navy was required to shut down or delay sonar use if a marine mammal was detected near the ship. Loud sonar pulses also were banned near coastlines and in certain protected waters.

Environmental groups, led by the Natural Resources Defense Council, filed a lawsuit in San Francisco in 2012, arguing the approval violated the Marine Mammal Protection Act.

The appellate court ruled 3-0 that the approval rules failed to meet a section of the protection act requiring peacetime oceanic programs to have “the least practicable adverse impact on marine mammals”.

“We have every reason to believe that the Navy has been deliberate and thoughtful in its plans to follow NMFS guidelines and limit unnecessary harassment and harm to marine mammals,” the appellate ruling said.

However, the panel concluded the fisheries service “did not give adequate protection to areas of the world’s oceans flagged by its own experts as biologically important,” according to a summary accompanying the court’s decision.

“The result is that a meaningful proportion of the world’s marine mammal habitat is under-protected,” according to the decision.