Aerial photo of blue whales. (NOAA National Marine Fisheries Service/Reuters)

They came as a wave, some 150 to 200 melon-headed whales churning into Hawaii’s Hanalei Bay like a single mass. It was a strange sight for the Kauai islanders to behold. Melon-headed whales live in the deep ocean, feasting on squid. But here they were, swimming in the shallows no more than 100 feet from shore.

Over the course of July 3 and 4, 2004, volunteers and rescuers shepherded the animals back to sea, according to the National Oceanic and Atmospheric Administration’s account of the mass stranding. The Washington Post reported at the time that it was the largest event of its kind in 150 years of Hawaiian history. Almost all the whales made it back out into the open water. But not the entire pod.

A young calf, split off from the rest of the herd, perished the next day.

A year later, 34 whales died when they were stranded at North Carolina’s Outer Banks. Three years after that and half the world away, 100 melon-headed whales were again stranded en masse, this time on the shores of Madagascar. The reasons why whales beach themselves are not always clear — strandings have been likened to car crashes in that the causes are myriad but the conclusion is never good. With the melon-headed whales, however, something was different. The events were unusual enough, and involved such large numbers, to prompt scrutiny. In both cases, a prime suspect emerged: sonar.

Controversy over these sound waves continues today. And in the latest skirmish over oceanic noise pollution, a victory went to the whales. On Friday, a federal appeals court in San Francisco ruled that the Navy violated marine mammal protection laws, reversing a lower court’s decision that allowed military vessels to use a type of loud, low-frequency sonar approved in 2012.

The National Oceanic and Atmospheric Association (NOAA) explains how sonar, short for "sound navigation and ranging," helps scientists explore the ocean. (NOAA)

Prior to the 2004 stranding, the problematic relationship between sonar and whales was thought to be likely, though not exactly clear. Once the melon-headed whales started appearing in the shallows, evidence began to accumulate. The acoustic blasts used to detect objects like submarines in deep water — up to a whopping 200 decibels, as loud as a rocket takeoff — had been used just prior to both strandings, in a U.S. naval exercise near Hawaii and by an Exxon Mobil contractor near Madagascar.

At the time of the Hanalei Bay incident, the Navy denied sonar was the cause. A spokesman for the Navy, Lt. Cmdr. Greg Geisen, told The Post in 2004 that “there is no evidence of a relationship here between the sonar use and the whale behavior.”

Later reports, however, found that sonar played a more pronounced role — possibly even a lead one. It increased by degrees. In 2006, officials considered sonar transmissions “a plausible, if not likely, contributing factor,” according to a statement from Brandon Southall, a biologist and the then-director of NOAA’s acoustics program. NOAA cetacean expert Robert Brownell, however, said at the time that sonar could create an “acoustic barrier” that the sensitive melon-headed whales would want to flee. Brownell continued to study the whale stranding, and again in 2009 concluded that sonar tests agitated the Hawaiian whales.

“It’s difficult to have conclusive evidence in most of these events,” Robin Baird, a biologist with the nonprofit Cascadia Research Collective in Olympia, Wash., told Science magazine in 2009, “but the weight of the evidence points to the Navy’s [midfrequency] sonar as the causal factor.”

Likewise, an independent review from the International Whaling Commission of the Madagascar event concluded in 2013 the contractor’s sonar system was “the most plausible and likely behavioral trigger.” It marked the first time researchers linked undersea sonar maps to whale deaths, as The Post reported.

Whales and other marine mammals have incredibly sensitive ears — blue whales can hear frequencies deeper than any human could hear, down to about 14 Hz. Whale songs can travel for thousands miles. “It’s important to understand that the ocean is a world of sound, not sight,” as Michael Jasny, director of the marine mammal program at the Natural Resources Defense Council, or NRDC, told Wired.

At the same time, sonar is a valuable technology that enables Navy ships to detect potential underwater threats. Early in 2008, a federal trial court judge in California ruled that naval ships using sonar had to steer clear of a 12-mile band along the coast — a sort of whale superhighway — and keep a lookout for whales for an hour before using sonar. This decision found its way to the Supreme Court in November 2008. Five justices concluded national security considerations outweighed environmental concerns. As a summary of the court’s opinion put it, antisubmarine warfare is “one of the Navy’s highest priorities.”

In 2012, the Navy moved forward with plans for a Surveillance Towed Array Sensor System Low Frequency Active sonar, or SURTASS LFA, a type of sensor array deployed in the Pacific Ocean that could identify distant submarines. In a biological opinion on the sonar system, the National Marine Fisheries Service wrote that although some animals exposed to the sonar system may be harassed, “We do not expect any threatened or endangered species to be injured or killed as a direct or indirect result of exposure to LFA sonar transmissions.”

Not everyone agreed SURTASS would be so easy on the animals’ ears. The NRDC, which had lost the 2008 Supreme Court case, argued it can disrupt the ability of marine mammals to breed, communicate and find food.

In the final ruling, NOAA Fisheries Service allowed for the “take” of six baleen whales, 25 toothed whales and 25 seals or sea lions over the half-decade the Navy wanted to use SURTASS.

The NRDC and other environmental groups sued, saying that allowing the potential deaths of these animals violated the Marine Mammal Protection Act. On July 15, the U.S. Court of Appeals for the 9th Circuit held that the final rule “did not give adequate protection to areas of the world’s oceans.”

The decision, Jasny wrote on the NRDC website Monday, was “a major victory, and not only for marine mammals, but for the law that protects them.” The case has been remanded to the lower court for further proceedings, the Associated Press reported.