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.
They've maintained the populations through seasonal bans to protect the area from (goat) grazing, and were also the first to successfully replant the trees.
At the end of the day, he says, it's the locals who have made the greatest impact.
"They're really the stewards and custodians of the trees."
Changing social perceptions
While the trees are important environmentally, locals also work hard to keep up with the booming business.
To make the oil, indigenous women peel the outer layer of the tree's fruit and pound its inner nut with a rock to extract kernels which are used to create the precious golden-colored oil.
It was Charrouf who helped establish a movement of women cooperatives, which she says plays a crucial role in progressing the lives of women in the region.
"Before they didn't get any money, but now they have at least 100 euros ($108) per month."
Previously it was uncommon for local women to work outside of their homes. But now, not only does the industry allow them to earn a decent wage, but gives them a sense of empowerment -- changing traditional roles and views of women within the local society.
"Before they couldn't send their children to school, and now all the ladies (who work for the cooperatives) have their children in education," Charrouf said.
"They are very, very happy and they are very grateful."