Authorities said the animal weighed about 7 tonnes. Male sperm whales, the largest toothed whales, could grow up to 45 tonnes. Adult female sperm whales are much lighter: 15 tonnes. They inhabit the deep ocean, can dive as deep as 600m, and feed on large squid, sharks and fish.
After the whale's death, government officials in Spain's Murcia region, where the animal was found, launched a campaign to raise awareness of humans' consumption of plastic and disposal of garbage in bodies of water.
Consuelo Rosauro, natural environment director in Murcia, said the presence of waste in seas and oceans threatens wildlife because many marine animals get trapped in the trash and ingest large amounts of plastic, which can be fatal.
Officials said the campaign includes cleaning up beaches in the Murcia region, gathering data about the type and quantity of marine litter and educational presentations.
This wasn't the first time a sperm whale turned up dead on shore, its body filled with rubbish.
At least 30 sperm whales have been found washed up on the beaches of the United Kingdom, the Netherlands, France, Denmark and Germany. Thirteen of them were found near the state of Schleswig-Holstein in northern Germany in 2016, according to National Geographic. A large amount of plastic waste, including fishing nets, a plastic car engine cover and remains of a plastic bucket, were found inside the whales' stomachs.
Last month, a 8.8m sperm whale was found dead on Indonesia's Lombok Island, east of Bali, though it's unclear how it died.
In the Philippines, the group Greenpeace Philippines installed a 14m-long replica of a dead whale on the shore of the seaside town of Naic in the northern part of the country. The structure was made of bamboo frame. Pictures taken by local media show the "dead whale's" gut spilling out, its mouth wide open and stuffed with plastic bottles.
"The Asean region's contribution to plastic pollution in the oceans cannot be ignored and is already way beyond alarming," Greenpeace Philippines's Vince Cinches said. "We are asking the Asean membership to take this issue with a sense of urgency and demand that our leaders initiate bold steps to address plastic pollution through regional cooperation, corporate responsibility and massive public education."
More than five trillion pieces of rubbish - and counting - are in the world's oceans, according to a 2014 study. Of that, nearly 270,000 tonnes of large and small plastic debris are on the surface. A study published last year found that 83 per cent of samples of water from more than a dozen nations were contaminated with plastic fibres.