Two decades ago, Miguel Angel Garcia harvested grapes and grains on his farm in central Spain, like his father and grandfather before him.
Now he produces pistachios -- a more lucrative crop that can better withstand the droughts that have become more frequent and intense in Spain.
Garcia harvests 10 to 20 tonnes of the green nut each year at his 26-hectare (64-acres) farm in Manzanares in the central region of Castilla-La Mancha, part of a boom in pistachio production in Spain.
"Wine and cereals weren't viable anymore," said the 58-year-old, who planted his first pistachio trees in 2007. "If I hadn't changed, I wouldn't have been able to make a living from my farm."
In the stony plot behind him, an electric harvester latched onto the trunk of a small pistachio tree and then shook it, causing nuts to fall into a vast canvas set up below, open like an upside-down umbrella.
Pistachio trees, which are native to the Middle East, are "resistant" and "adapted to the climate we have here" with its hot and dry summers and cold spells in winter, Garcia said.
The amount of land devoted to pistachio trees in Spain has jumped nearly five-fold since 2017 to 79,000 hectares (195,000 acres) in 2024, according to agriculture ministry figures.
This makes Spain the biggest pistachio grower in Europe in terms of surface area, and the world's fourth-largest after the United States, Iran and Turkey.
Most pistachios are grown in Castilla-La Mancha as well as Extremadura in the west and Andalusia in the south, which are facing water shortages due to climate change.
This crop comes from a "desert region" and is "much better adapted" to the new climate realities, said Mario Gonzalez-Mohino, an agricultural engineer and the director of the specialist website Pistacho Pro.
Spain experienced its hottest August on record this year, with temperatures averaging 25 degrees Celsius (77 Fahrenheit) -- and the national weather agency says 2024 could rival 2022 as the warmest ever registered.
Spain's production -- nearly 9,000 tonnes per year -- is "still limited" but "it will increase rapidly because the vast majority of plots have not gone into production", since it takes at least seven years before a newly planted tree gives its first harvest, he added.
Joaquin Cayuela Verges, secretary general of the Pistamancha agricultural cooperative that groups 51 pistachio farms, said the boom had only started.
"There is strong demand, it's a dynamic sector," he said.
The cooperative, based in the town of Pozuelo de Calatrava, sells 90 percent of its pistachio production in Europe, mainly France and Germany, at 10-11 euros per kilo (around $5 a pound).
To keep up with its rapid expansion, Pistamancha is spending five million euros to build a new plant to sort, peel and dry its pistachios.
It will be able to process one million kilos of pistachios per year when completed, Cayuela Verges said.
Can this boom lead to overproduction that will drive down prices? Those involved in the industry see little risk since the amount of pistachios produced in Spain falls well short of domestic demand.
In Spain pistachios are still "mostly imported", mainly from the United States, said Gonzalez-Mohino, who predicts a "bright future" for national producers of the crop.
Pistachios are mostly eaten as snacks but are also widely used in Middle Eastern cuisine, as well as in the production of cakes, sweets, ice cream and cosmetics.
"A lot of people think they'll get rich but when you plant pistachio trees, you have to realise that you won't get anything for several years" until the trees "start bearing fruit", Garcia said.
"I have been investing" in this crop for 15 years and "it's only now that I can recoup what I have spent and earn a living. Pistachios are a matter of patience," he said.