Beachgoers help push beached whale that came near the shore of a beach on St Simons Island.

Dozens of beachgoers and lifeguards battled to help a pod of pilot whales back into deeper waters after coming too close to the shore of the US state of Georgia earlier this week, although authorities said that three of the animals had died.

Around 50 short-finned pilot whales were spotted in the shallow waters off St Simons Island on Tuesday, the Georgia's Department of Natural Resources (DNR) said in a statement.

Nine pilot whales - a species of oceanic dolphin that grows 7 metres long and can weigh up to 3 tonnes - stranded themselves in the surf and while rescuers where able to push six back into deeper water, three perished, the DNR said.

Onlookers captured the impromptu rescue on videos that have since drawn hundreds of thousands of views online. The footage showed several glossy black pilot whales flailing in knee-high water surrounded by small groups of people trying to push them away from the shallows.

Faith in humanity restored a little bit today... this huge family of Pilot Whales got too close to shore in St. Simons Island, GA, and a tremendous group of people helped push them back to deeper waters pic.twitter.com/o7tadxJIkQ — Lauren Bugaj (@Lauren2point_oh) July 16, 2019

Officials checked beaches and marshes along the island's coast by helicopter and did not spot anymore stranded whales, the DNR said.

Clay George, a biologist with the Georgia Wildlife Resources Division, told the New York Times that "something when wrong" for the creatures, which normally swim 100 miles (160 km) offshore.

"We're cautiously optimistic that the group dodged a bullet and that they're now on their way to deeper water," Clay was cited as saying.

More than 100 pilot whales died in a mass stranding in New Zealand last year. It is not known why whales sometimes beach themselves. But the whales travel together in pods and are known to follow a leader, as well as gather around an injured or distressed whale, officials said.