Rain had come to nearby villages, but not yet to Droum in south-east Niger. The sand under its stately trees looked completely barren, but Souley Cheibou, a farmer in his 60s, was not worried. He crooked a finger, fished in the sand, and brought out a millet seed. In a week or two, this seed would germinate and sprout, and soon the whole field would be green.

Cheibou’s peace of mind stemmed from the trees encircling him, which had been standing long before he was born. Despite appearances, these were not any old acacias. They were gao trees – known as winterthorns in English – with unique, seemingly magical powers.

From the peanut basin of Senegal to the Seno plains of Mali, to Yatenga, formerly the most degraded region of Burkina Faso, and as far south as Malawi: gaos are thriving in Africa. And over the past three decades, the landscape of southern Niger has been transformed by more than 200m new trees, many of them gaos. They have not been planted but have grown naturally on over 5m hectares of farmland, nurtured by thousands of farmers.

Facebook Twitter Pinterest A valley near the town of Dogondoutchi in the east of Niger. The valley is completely devoted to rainfed cropland. Photograph: Gray Tappan

According to scientists, what has happened in Niger – one of the world’s poorest countries – is the largest-scale positive transformation of the environment in the whole of Africa. This is not a grand UN-funded project aiming to offset climate change. Small-scale farmers have achieved it because of what the trees can do for crop yields and other aspects of farming life.

“It’s a magic tree, a very wonderful tree,” said Abasse Tougiani of Niger’s National Institute of Agricultural Research, who has travelled all over Niger studying Faidherbia albida – the gao’s Latin name.

Shielded from the sun, crops planted under the canopy of a tree usually do not do well in the short term, although there can be longer-term benefits. That’s one reason why many west African rainforests have been decimated. But with gaos, it’s the other way round. The root system of the gao is nearly as big as its branches, and unusually it draws nitrogen from the air, fertilising the soil. And unlike other trees in the area, gao tree leaves fall in the rainy season, allowing more sunlight through to the crops at a key moment.

Used along with mineral fertilisers, crop yields double under gaos, and the gao-nourished soil holds water better, ensuring a better crop in drought years.

Facebook Twitter Pinterest A seed-pod of the gao tree. Photograph: Ruth Maclean/Ruth Maclean for the Guardian

Counterintuitively, the great gao regreening is only happening in areas of Niger with high-density populations. With less space to expand into as more people are born, hard-up farmers are increasingly realising that the trees can regenerate degraded land.

“It’s literally a story of more people, more trees,” said Chris Reij, a sustainable land management specialist. “The whole point is that the trees are not protected and managed by farmers for their environmental beauty, but because they are part of the agricultural production system.”

Inadvertently, the farmers are also doing their bit to offset climate change. Trees are crucial for storing carbon, absorbing it out of the atmosphere. “In mature, fairly dense areas, you get 30 tons of wood per hectare. Half of that is carbon,” said Gray Tappan, a geographer.

Facebook Twitter Pinterest The guards of Droum gather outside the district chief’s palace. Photograph: Ruth Maclean/Ruth Maclean for the Guardian

Efforts to restore 100m hectares of degraded African land by 2030 are underway. The ambitious Great Green Wall project to surround the Sahara desert with trees and other plants has changed beyond recognition after debate over whether desertification - the process by which soil loses its fertitlity - is real. Progress is slow. In Niger, where temperatures often reach the 40s, the trees create a cooler microclimate, and rabbits and jackals are coming back.

But none of these grand political projects explains why gaos have caught on. The trees’ pods make very nutritious animal fodder, and fallen branches make good firewood, meaning Droum’s women and children – whose job it is to collect fuel for cooking fires – rarely have to venture further than a few kilometres to find it.

Facebook Twitter Pinterest A Droum resident with the village’s mature gao trees. Photograph: Ruth Maclean/Ruth Maclean for the Guardian

Women in Droum have also made medicine from their gaos for generations. “People come all the way from Zinder [Niger’s second largest city] to buy it,” said Husseina Ibrahim, a busy mother, next to a pot of boiling gao bark. “I’m the only one who makes this here. It’s great for me, it earns me a bit of money which I pay into the women’s cooperative.”

Tales about how the gao came to be so revered abound. Legend has it that crimes against gaos have been taken very seriously since the mid-19th century. “If you touched a branch, you would go to jail,” Tougiani said. In splendid brocade robes and curly-toed velvet slippers, surrounded by self-portraits and stick-wielding guards dressed in red and green, today’s district chief in Droum takes a slightly softer approach.

Facebook Twitter Pinterest Gao bark powder and infusion, which locals say cures haemmerhoids. Photograph: Ruth Maclean/Ruth Maclean for the Guardian

“It’s shameful to have to come before the chief and explain yourself. Often that’s punishment enough,” Maman Ali Kaoura said. Droum’s reoffenders face fines of between 5,000 to 10,000 West African CFA francs (£6.75-£13.50), a huge amount for hard-up farmers.

A sense of ownership has been key in the regreening of Niger. Until the mid-1980s, every tree was considered to belong to the state. When this changed, regreening began, as people were happier to look after trees that belonged to them. In areas with the best cover, they organised patrols to protect their trees from passing farmers and neighbouring villagers seeking firewood.

Once people discovered that “one gao was equal to 10 cows” for fertilising, as Tougiani put it, the tree’s popularity took off. Several schemes, including one where farmers with more than 50 gaos were paid 50 CFA for each one, helped it along.

Facebook Twitter Pinterest A Droum farmer opens his millet store. Photograph: Ruth Maclean/Ruth Maclean for the Guardian

But their loyalty to their gaos could make areas around Zinder the most vulnerable to a disease that Reij and Tougiani have recently spotted killing trees near Niamey, the capital. If it spreads, the losses could be enormous, particularly in places where there is a near-monoculture of gaos.

“I’m worried, because it’s green oil for farmers – it’s their wealth,” said Tougiani. “If they lose Faidherbia albida, they’ll lose their way of life. They’ll have to leave the village.”

Quick guide What is the Upside? Show Hide Ever wondered why you feel so gloomy about the world - even at a time when humanity has never been this healthy and prosperous? Could it be because news is almost always grim, focusing on confrontation, disaster, antagonism and blame? This series is an antidote, an attempt to show that there is plenty of hope, as our journalists scour the planet looking for pioneers, trailblazers, best practice, unsung heroes, ideas that work, ideas that might and innovations whose time might have come. Readers can recommend other projects, people and progress that we should report on by contacting us at theupside@theguardian.com

Sign up here for weekly emailed updates from this series

For Cheibou, losing his trees is unthinkable – they were his birthright. “I have nearly 100 gao trees in my fields, which I inherited from my father,” he said. On his way back to the village, he paused by a particularly large one, and cracked open its round seedpod. “This one was here when I was a boy. Just like it is now.”

This article is part of a series on possible solutions to some of the world’s most stubborn problems. What else should we cover? Email us at theupside@theguardian.com