A stranded adult sperm whale weighing more than 30 tonnes has died after becoming stuck on a sandbar off a West Australian beach.
The massive mammal, about 15 metres long, was first spotted at Fremantle on Saturday, exhibiting concerning behaviour.
It reappeared on Sunday swimming in circles before beaching itself close to shore on Monday at Rockingham, in Perth's south, after being hit by a boat.
Authorities enforced a safety perimeter as hundreds of people gathered to see the whale, which was about 50 metres from the beach.
Marine mammal expert Kelly Waples said it was an unusual sight as sperm whales usually lived in deep water.
"It's never a good thing when you see a whale like this so close to shore," she told reporters.
Before it died the whale was distressed and thin and resting on the sand, with the weight of its body pressing down on its organs.
"Normally this is an animal that's supported fully by the seawater," Dr Waples said.
"That kind of compression is a very bad situation to be in and it reduces its health even further."
Veterinarians worked through Monday to assess the whale that was partially protruding from the water and in poor condition.
It was found to be breathing very slowly and suffering.
Staff from Perth Zoo and the Parks and Wildlife Service then devised a plan to humanely euthanise it.
Authorities continued to monitor the whale throughout the night, saying there was little they could do to help due to its size and weight.
The animal moved into deeper water in the early hours of Tuesday morning but was reported to have died several hours later after marine scientists observed it hadn't breathed for 45 minutes.
"It was moving pretty gingerly and swam only two or three hundred metres before it really seemed to stop its respiration and gave us some signs it really was coming to the end," Incident Controller Mark Cugley said.
"There was no external trauma or injuries or obvious disease ... but once we're able to completely remove the whale from this site we will see about undertaking a necropsy to understand more about its health."
Crews are maintaining a safety perimeter around the carcass and local Noongar Aboriginal groups will hold a ceremony for the dead whale
Authorities are working on a plan to move the carcass further away from the beach and remove it from the water.