Haraz, a collection of medieval villages in Yemen’s highlands, feels very far away from the devastation of the country’s civil war. Banks of cloud tumble down green farming terraces and caress the gingerbread-like houses clinging to the mountainside, and the unique environmental conditions create some of the best coffee in the world.

Yemen has exported coffee since the 1400s: the Red Sea port of Mokha gives chocolatey coffee its name. Although native to Ethiopia, the coffee plant was developed into the form that gives us the modern beverage by Sufi monasteries in Yemen that shared it with traders and pilgrims. Eventually, coffee made its way to Constantinople (now Istanbul), Baghdad and London, leading to the rise of the coffee house.

Today the global coffee industry is worth £61.4bn, making coffee the most valuable trading commodity in the world after oil. Decades of political instability, however, mean that the quality and availability of Yemeni beans has fluctuated – but now a growing handful of dedicated farmers and exporters are determined to restore Yemen’s reputation as the birthplace of black gold.

One of the traditional mountaintop villages in the mountains of Haraz. Photograph: Michele Falzone/Alamy Stock Photo

“My family has grown coffee here for 200 years,” said farmer Hassan Ahmed Alsalool, 35. “I had a motorcycle parts shop in Sana’a, but when the war broke out business dived and I struggled to get parts imported from China. I went home and decided to give coffee growing a try. I feel more free here and the work is rewarding. If you are good to the land, it will be good back to you,” he said.

Yemen has long suffered from chronic water management problems, an issue exacerbated by the country’s fondness for khat, a mild narcotic leaf chewed by most men. At least half of the water drawn from ever-depleting aquifers for agricultural purposes is used to grow khat, a quick turnaround crop, rather than the corn or millet that the food-insecure country desperately needs.

Khat and money change hands in a Yemen marketplace, but now the khat trees are making way for coffee plants. Photograph: Marco Di Lauro/Getty Images

In Haraz, more and more locals are deciding to clear the terraced farmland of khat and grow coffee instead – a move that could revolutionise Yemeni agriculture. Around 2m khat plants in the area have been cut down and replaced with coffee and corn in the last decade.

Coffee growing is still hard work: it takes a few seasons for a crop to reach maturity, so many farmers require financing to get started. Small exporting companies such as Mokha Route, Port of Mokha and Mokha Mountain offer interest-free loans and train farmers in the use of moisture analysers, modern drying beds and organic fertilisers.

The ripe, red coffee cherries are then picked, dried, aged and the beans separated from the husks by hand.

The high altitude terrain is prone to drought, so farmers like Alsalool are constantly building and maintaining small dams to channel run-off rain from the top of the mountains.

Workers dry coffee beans in the sun at a field in Haraz. Photograph: EPA

The difficult conditions mean yields are small but the Haraz product is critically acclaimed worldwide for unique and diverse tones of caramel, chocolate, spices and vanilla all the way though to aromas of lemon, guava, forest berries and apple.

The Saudi-led blockade of Yemen’s airspace and borders, which poses significant challenges to getting fuel, medicine and food into the country, also creates problems for fledgling coffee exporters.

The dried coffee beans. Photograph: EPA

Alasool sells his coffee for $18 (£13.8) a kilogram. The sought-after product is then sold to buyers mainly in Saudi Arabia, South Korea, Japan and the US, where it can sell for almost $500 a kilogram – the most expensive, and arguably the best, coffee in the world.

Buyers like Ahmed Taher of Mokha Mountain are proud to pay Haraz’s farmers and producers well to encourage best practices and re-establish Yemen’s coffee industry.

“It’s been very hard work establishing the farmers’ collective here but we are very optimistic about the future and the growth of the business. The demand is very high, understandably, for our high quality product.

“I never thought that the war would have an upside, but so many of us have rediscovered our roots in our ancestral villages and the practices that sustained our fathers and grandfathers. It is a very special tradition.”