SARRIÓN, Spain — On Saturday nights, prospective buyers gather on the outskirts of this small village, in the darkness of a parking lot next to a semi-abandoned railway station. Using flashlights, they inspect the offerings local farmers have piled in the trunks of their vehicles, then haggle over price.

It might seem an unusually clandestine way to sell produce. Then again, this market is for one of the world’s most prized foodstuffs, the black truffle.

But perhaps more surprising is that a truffle trade would be thriving here, in the arid and thinly populated hills of east-central Spain.

The black truffle, with its pungent aroma, is, after all, a mainstay of French gastronomy. Spaniards barely eat them. Scientifically known as the Tuber melanosporum, it is even commonly known as the Périgord truffle, after the French region that long led in its production.

More than a century ago, farmers in southern France took up the harvesting of black truffles after an epidemic of aphidlike phylloxera destroyed vineyards, forcing a search for alternatives.

But France’s truffle output has collapsed over the past century, through wars and industrialization that encouraged farmers to switch to crops with shorter production cycles. Changes in the climate — severe droughts and heat waves — have also hurt production recently.

“With the heat waves we’ve recently had, my plantation now gives next to nothing,” said José-Gabriel Sánchez, who grows truffles in Cotignac, in the southern Var department of France.

“I think climate change has literally driven us out as a truffle production area,” he added.

Last year, France produced 56 metric tons of truffles, compared with a peak of 1,040 tons in 1904, according to historical data from the French federation of truffle growers.

At the same time, Spain’s production has been growing rapidly — to about 45 tons a year.

Luckily for the French, and others, however, Spanish cuisine rarely uses the truffle. In fact, about 95 percent of what Spain produces is exported to France and other markets — even if some of it gets relabeled as Périgord truffle.

“Spain is now producing what is missing in France,” said Eric Bienvenu, a French truffle broker, who buys truffles from farmers to supply French restaurants.

The quality of the Spanish black truffle, he argued, is “at least as good” as that grown in France, “even if most French will of course tell you that theirs are better.”

For 2016, the regional government of Aragón, Spain, has also pledged to pay for most of a $17.5 million irrigation system that will further help truffle farmers.

“It’s evident that Spain has done in recent years a huge amount of work to raise production, which hasn’t been done in France,” said Michel Courvoisier, the French federation’s director.

The shift to Spain has been helped by a production method initially developed in France that allows a fungus to be injected into the root of a sapling. The sapling is then grown in a greenhouse before being transferred to a field.

After about three years, each tree starts producing one truffle a year, harvested between December and March.

The truffles grow a few inches below the ground, but within the smelling range of hunting dogs that are trained to find them by farmers, like sniffer dogs that are trained by the police.

Truffles have already become a big business here, which has also helped stem the population decline in the villages scattered around the district of Gúdar Javalambre, of which Sarrión, with its 1,100 inhabitants, is the largest.

“We’ve done everything to revive farming here and lead Europe’s truffle production, but it’s now about getting international recognition for that,” said Joaquín Olona, the official responsible for rural development within the regional government of Aragón.

The truffles have also helped diversify the population by bringing in migrant workers. Eladio Salvador Redón, the owner of a truffle farm, employs five truffle pickers, all of them Moroccan.

They spend much of their working day on their knees, digging around the roots of the trees with a trowel, wherever the dog stops and starts to scratch the soil.

“It’s a good but hard job, especially because the winter can get really cold here,” said El Mostafa Marnouch, 35, who is originally from Casablanca. He said he earned 800 euros a month, or about $874, picking truffles.

The black truffle has a wholesale price of about 500 euros per kilogram, or about $546, according to local farmers. This has led many of them to place surveillance cameras around their fields, while also explaining why they transport and sell their truffles with some degree of secrecy.

But the most sought-after truffle is the white one, grown mainly in the Piedmont region of Italy, which sells for about five times as much as the black variety.

In December 2014, a giant white tuber was auctioned by Sotheby’s, fetching $61,250. While the white truffle also has a distinct aroma, part of its appeal is its rarity: It grows only in the wild and has so far resisted scientific cultivation efforts.

Producers here estimate their district of Gúdar Javalambre now accounts for more than half of Europe’s truffle production. According to the French federation, however, Spain’s production in 2014 still slightly lagged France’s. So far this year, eastern Spain has also been hit by a particularly mild and dry winter, which is likely to delay the harvest.

In any case, contrasting data in the truffle sector is complicated because the business is “completely opaque,” said Bienvenu, the French broker. He said three-quarters of his transactions were made in cash, largely because farmers did not want any billing paperwork.

In December, the regional authorities of Aragón published the first official pricing list for truffles, in part to get marketers out of the darkness of their parking lot.

“We need to make this sector a lot more transparent,” said José Manuel Martínez Matías, an agricultural engineer who helps run an association of truffle producers.

An official pricing system, he suggested, would also encourage Spanish restaurateurs to add truffles to their menus.

“At the moment, it’s just very hard for any outsider to know how to buy truffles,” he said.

Manuel Doñate, a local producer, said the main challenge for Spanish truffle growers, however, was not necessarily opaque pricing or weather changes, but rather persuading Spaniards and chefs here to include truffles in their cuisine.

“Truffle is the missing element in Spanish gastronomy,” he said.