The hungry animals would climb onto the thorny trees, native to Morocco, and eat their fruit and leaves.
But the kernels, which are encased within the fruit's incredibly strong nut, couldn't be digested by the goats. So enterprising locals collected them from the animal's droppings and turned them into precious golden oil.
The oil, now produced by local indigenous women, has been used for centuries by locals for medicinal and culinary purposes. But recently it's gathered a cult-like following in the global cosmetic market. Full of antioxidants and vitamin E, the oil has been praised as having conditioning and anti-aging properties that benefit both hair and skin.
However, because of this surge in popularity, agricultural exploitation and climate change has left the Argan trees struggling to survive.
'The last curtain in front of the desert'
Once Argan trees covered the entire region of North Africa, but due to overgrazing and deforestation their numbers rapidly declined.
For a while, the value of the trees went unnoticed -- until the oil industry boomed -- bringing more than $6.5 million per year into Morocco's economy.
Professor Zoubida Charrouf at Mohammed V University in Rabat, Morocco, said the trees -- which are under the protection of UNESCO and in a 'biosphere zone' -- are incredibly important, not just economically but environmentally.
"They say they're the last curtain in front the desert," she said.
The trees have deep roots which help provide soil stabilization by absorbing water and protect the local environment from desertification.
Director of the Global Diversity Foundation, Gary Martin, said Argan trees are one of the very few trees in the world that "anchor the ecosystem."
"If you remove the Argan tree from the biosphere reserve you'd have a major impact on the ecosystem."
The high demand in Argan oil has prompted organizations to implement a series of conservation measures to ensure tree numbers don't dwindle. Now, the Argan forest is more than 800,000 hectares in size and every year, more and more trees are being planted.
"Before, nobody planted the tree but now the government is planning on planting 200,000 hectares of trees by 2025," Charrouf said.
Anastasiya Timoshyna, co-chair of the Medicinal Plant Specialist Group at the International Union for Conservation of Nature (IUCN), said the high demand for Argan oil was "excellent" as it gives the country an opportunity to tie conservation with its economic goals.
"I think Argan oil is a fascinating ingredient because people talk about it and celebrate the fact it's coming from the wild."
She said this is one of the many reasons why Western companies are working in a more ethical way.
"It brings alive the stories of people on the ground and draws attention to whether it's sustainable."
But while the government and organizations are doing their bit to ensure sustainable development, Martin says it's the locals who play a biggest role.
"The biosphere reserve is good recognition, but the fact is these trees have been planted, manged and really maintained by the local population," he explains.
The indigenous people, he says, have the greatest environmental knowledge and truly understand the value of the Argan trees.