Rescue crews and biologists were seen using underwater microphones, known as hydrophones to guide get a large humpback whale back to the ocean after it got stuck in the Ventura Harbor Marina in California on Saturday afternoon.

The rare spectacle of an almost 40-foot-long whale swimming in circles between docks at the Ventura Harbor Marina attracted a large audience and television cameras, the Los Angeles Times reported.

ReadMost Polluted Animal On Earth: Dead Killer Whale Washes Up In Scotland

The whale was said to have been trapped in the finger of the M dock between Ventura Isle Marina and Ventura West Marina.

According to the authorities, the whale appeared to be angered as it swirled sand and dirt and muddied the water at the end of the dock. The humpback whale also hit the dock a few times and crashed into the rear end of a boat, almost hitting a propeller.

Ventura Harbor Patrol Officer Tim Burrows confirmed the mammal was not injured. Large crowds of people gathered in the parking lot area above to watch the large mammal swim around the docks.

According to a wildlife expert at the Channel Island Marine and Wildlife Institute, Jen Levine noted it to be a healthy juvenile, Associated Press reported.

Local authorities, the Coast Guard, and the National Parks Service were also involved to help rescue the mammal.

Humpbacks range in length from 39 to 52 feet and weigh between 50,000 to 80,000. These whales can live for almost 50 years.

The humpbacks are well known for breaching and other distinctive surface behaviors, making them quite popular with their spectators and whale watchers.

“It’s really beautiful when they are swimming under the sea ice,” scientist Ari Friedlaender, an ecologist with Oregon State University's Marine Mammal Institute, told National Geographic. “They’re so fluid and moving around in three dimensions and just cruising. But to be honest, we don’t know what everything we’re watching means yet.”

Their diet mostly consist of krill and small fish, and they typically migrate up to 16,000 miles each year.

Humpbacks are known for their magical songs that travel large distances across the world’s oceans. Males are said to produce a specific song, which lasts from 10 to 20 minutes and they repeat it for hours at a time. Researchers say this song might have a role in mating.

Like other large whales, the humpbacks have also been a target for the whaling industry. They were once hunted to the extent of being on the brink of extinction. Its population fell by an estimated 90 percent before a 1966 moratorium. While the number has partially recovered after that, collisions with ships, noise pollution and entanglement in fishing gear still continue to affect the population of 80,000 humpback whales.

Earlier in May, researchers attached cameras to the large mammals’ backs in Antarctica in order to follow their movements. The cameras were attached with suction cups that didn’t hurt the whales and remained there for a day or two, National Geographic said.

They tracked the creatures and captured “a whale's-eye view of a changing undersea universe, helping reshape our knowledge of whale life in the Southern Ocean.” And these cameras did that without the sometimes harmful intervention of humans into their underwater world.