Aldo Sánchez surveys a field of lofty banana trees, with cacao plants bursting with fruit nestled beneath. “Two and a half years ago, this was pure pasture,” he says. Indeed, his neighbour’s field is just grass.

Four decades ago, a swath of land including his farm in Jabillos in central Costa Rica was deforested to plant coffee. It was later turned over to cattle, but ranching dried up when prices collapsed. Cacao — the raw material for chocolate — had not been planted since the late 1970s, when the monilia fungus wrecked 80 per cent of the national crop.

“Even 10km away, people couldn’t believe we were planting cacao because the last people to do that were their grandparents,” Mr Sánchez says.

His farm is a successful example of agroforestry — the sustainable combination of crops with trees — that is complementing Costa Rica’s remarkable reforestation in the past three decades.

Today, with exuberant tropical vegetation cloaking its countryside, it is hard to imagine that the Central American nation of 5m people could once have been any greener.

It has built a reputation, and a thriving eco-tourism industry, based on being a biodiverse natural paradise. The country boasts more than two dozen national parks, as well as rainforests, cloud forests, tropical dry forests, conservation areas and incredible wildlife.

© Alamy

But in the 1970s, Costa Rica’s deforestation rates were among the world’s worst. By some estimates, forest cover plunged to just 25 per cent of the country. Other experts say its lowest point was 40 per cent.

After the removal of cattle subsidies in the mid-1980s, and a landmark forestry law in 1996 that banned deforestation and introduced a pioneering payment system to champion reforestation and biodiversity, forest cover is now back to 52 per cent.

For small farmers like Mr Sánchez, agroforestry makes economic as well as environmental sense. Trees provide shade, compost and a habitat for the flies that pollinate the cacao, and bananas are harvested every two weeks, supplying a steady income.

Besides his own farm, he is project administrator for Rausch, the German fine chocolate company, which has planted 30 hectares with cacao in agroforestry systems.

“This is an example of how to reforest land that had been deforested and was very poor,” says Wiebke Niether, deputy head of the cocoa department at Rausch’s Tres Equis ranch.

Some plots have struggled. But in others the cacao has flourished alongside a variety of trees and shrubs.

Company photographs show how fields that were bare in 2014 were lush within three years. Production is about to start and the company plans to add it as a speciality chocolate to its range of single-origin bars.

Securing a market is crucial to sustainably combining crops and forestry.

Amelia Paniagua-Vásquez of the National University of Costa Rica, which pioneered the introduction of vanilla crops on deforested land, hosted a delegation from Chanel, the French luxury brand, keen to compare Costa Rican vanilla with that of the world’s biggest producer, Madagascar.

She has advised on combining the trailing plant — a variety of orchid — with native forest species and tropical fruit trees. In the country’s biggest vanilla farm, in Guápiles in central Costa Rica, 1,700 plants have been sown in rows together with trees on what was deforested pasture land. They are pollinated, harvested and dried by hand.

A dense forest serves as a “nursery” with seeds provided by vanilla growing below the trees. Without agroforestry, “I don’t think vanilla would be successful — even though current prices are good, agroforestry provides sustainability over time and helps combat climate change”, she says.

The farm last year produced 3kg of finished vanilla but Ms Paniagua-Vásquez says this year’s yield could triple that. “From our feasibility studies, any price over $50 per kg is profitable,” she says. Once national organic certifications are complete, the price could rocket to $1,000 per kg.

Agroforestry is not just changing farmers’ fortunes, but the face of the landscape.

Macario Fuentes Martínez inherited his land from his grandfather. Back in the 1940s, it was forest. “They cut it down and sowed sugar cane and, mostly coffee — it was the coffee boom years with government incentives,” he recalls.

Now, the land is densely wooded, with thick forest on the hilltop behind his house leading not to stripped pasture but secondary woods planted with cacao and coffee.

He complements the farm with cabins for tourism. As Bryan Finegan, head of forests, biodiversity and climate change at the Tropical Agricultural Research and Higher Education Center (Catie), put it: “Eco-tourism brings people who want to see forests.”

Costa Rica now regenerates about seven times more trees than it cuts down, according to Víctor Milla Quesada, assistant representative for the UN’s Food and Agriculture Organization in Costa Rica. But “we’re not at all past the point of no return,” says Mr Finegan, noting fire risks from climate change-induced droughts could threaten forest recovery.

Furthermore, the land expectation value for conserving forests or selling the timber earns farmers only about $1,000 to $1,500 per hectare per year, during a productive cycle of 15 years, while pineapples from monoculture farms — Costa Rica is the world’s largest exporter — can net as much as $15,000 over a 15-year period, Mr Milla Quesada says.

But for farmers like Mr Sánchez, diversity brings benefits. “We need the interaction of the species,” he says. “It’s magic.”