On the volcanic slopes of Hawaii’s Big Island, hundreds of farmers in the Kona region produce one of the most expensive coffees in the world.

Those farmers recently won a series of settlements — totaling more than $41 million — after a nearly five-year legal battle with distributors and retailers that were accused of using the Kona name in a misleading way.

The class-action lawsuit, aided by a novel chemical analysis of coffee from Hawaii and around the world, prompted some companies to include the percentage of authentic Kona beans on product labels. The plaintiffs said they hoped the hefty settlements — the last of which will likely be paid this spring — would deter others from selling fake Kona.

“There are probably many, many more marketers of coffee who have misused geographic names in marketing, and this will be a disincentive,” said Bruce Corker, who owns the Rancho Aloha coffee farm in the Kona district.

Mr. Corker practiced law in Seattle until 2001, when he and his wife moved to Hawaii. He had learned to grow coffee three decades earlier while in the Peace Corps in Colombia.

Kona coffee, known for its mellow and sweet notes, thrives in the mineral-rich soil. The plants receive lots of rain, and the land’s incline provides excellent drainage. Red cherries are picked by hand and “pulped” to separate the seeds, which are dried in the sun. Milling then produces green coffee beans for roasting.

The Kona belt includes some 600 to 1,000 farms, typically smaller than five acres. The limited supply, labor costs and unpredictable pest problems put a high price on the beans, around $50 a pound or more.

Mr. Corker said farmers had long been frustrated by the ubiquitous “Kona” beans sold by souvenir stores, coffee shops and larger retailers. They strongly suspected that the products were fake: They were far too cheap.

In 2013, a U.S. Supreme Court case caught Mr. Corker’s attention. The court found that Pom Wonderful, which sells pomegranate juice, was allowed to sue Coca-Cola for marketing a “Pomegranate Blueberry” juice that was in fact more than 99 percent apple and grape juices.

“The decision said, if you’re harmed by false labeling, you can bring a case for damages,” Mr. Corker said.

In 2019, he filed the lawsuit on behalf of Kona farmers against more than 20 companies. At the center of the complaint was a chemical analysis performed at a private lab in Salt Lake City.

James Ehleringer, a biologist at the University of Utah who ran the analysis, said that standard tests depended on the amount of water in each sample. That wouldn’t have worked on the variety of Kona products at issue.

“As you go from green beans to roasted beans, you’re changing the water content,” he said. So he borrowed an approach from geology that instead looked at the relative concentrations of rare, inorganic minerals in the beans. These ratios, he said, stay constant even at roasting temperatures.

After testing coffee samples from around the world as well as more than 150 samples from Kona farms, Dr. Ehleringer’s team identified several element ratios — strontium to zinc, for example, and barium to nickel — that distinguished Kona from non-Kona samples. “We were able to establish a fingerprint for Kona,” said Dr. Ehleringer, who described the general method in a 2020 study. “It’s the characteristics of the volcanic rock.”

Those chemical signatures, he found, were largely absent from samples of coffee labeled “Kona” sold by the defendants.

Dr. Ehleringer said that the method was easy and cheap — about $50 per sample. Other researchers have used a similar approach to test honey, oils, onions and wine.

Some defendants contested the testing in a legal motion, arguing that Dr. Ehleringer’s data had not been replicated by other labs. (The case was settled before a ruling was made on the motion.)

Proving a legal claim of false advertising boils down to more than the product’s geographic origin, noted Rebecca Tushnet, a professor at Harvard who specializes in advertising law and has written about this case.

French fries, for example, don’t have to be made in France, and Swiss cheese doesn’t have to come from Switzerland. “The question is, what does Kona mean?” Ms. Tushnet said. “The plaintiffs say Kona means it’s grown in that region. If that’s what consumers believe, then that’s what they’re entitled to get.”

The case was settled before the court could answer that question. The largest settlement, $12 million, came from MNS, a company that operates a chain mostly in Hawaii called ABC Stores. Another Hawaiian outfit, Mulvadi, which sells coffee to outlets including ABC, Amazon and Walmart, offered the farmers $7.775 million. Neither company admitted wrongdoing. (The lawyer representing MNS declined to comment. Counsel for Mulvadi and several other defendants did not respond to requests for comment.)

Dexter Washburn, a retired Kona farmer and former lawyer who helped Mr. Corker bring the lawsuit, said that the best way to find real Kona is to buy directly from a farmer, whether in person or online. “I don’t trust anything you buy in the store,” he said.

Jack Begg contributed research.