HANALEI, Hawaii — It's a warm Tuesday afternoon on Kauai and tourists are lining up — just a few at first, then a dozen or so. Finally more than 100 have gathered, waiting patiently. They're not here to swim with dolphins, snorkel in turquoise waters or even learn to hula at a luau. They're here for a farmers market.

Manager Kalen Kelekoma climbs atop a wooden crate and welcomes the throng with a warm "aloha" and an explanation of the market rules. Then the horn sounds, and they rush the stalls. Some head straight for the obvious draws on this hot day — ice-cold coconuts and soursop ice cream. Others start grabbing tropical fruits they rarely get a chance to taste on the mainland — rambutans, longans, lychees and mangosteens. Some buy salad greens and broccoli.

Agriculture has become a tourist draw in Hawaii, which imports about 85% of its food but used to export almost everything it grew — tons of pineapples and sugar cane. In just one week on the islands, I slept on a farm, toured a coffee plantation, learned how chocolate is grown and much more. Yes, the beaches are a draw — snorkeling at Two-Step on the Big Island was unforgettable. And sure, some people still want to see hula and go to a luau.

For almost all, it's an economic lifeline — a chance to add a few dollars to a bottom line that has been steadily shrinking for the last 20 years.

Perhaps most unexpected, Hawaii now boasts farm-to-table restaurants, which source many of their ingredients from small farmers, often identifying those growers on the menu. That might not be unusual on the mainland, but here in the land of the "plate lunch" — ice-cream scoops of mushy rice and macaroni salad flanking a piece of long-cooked meat — it's a welcome surprise.

The big kahuna of the farm-driven restaurants in Hawaii is Peter Merriman, who started with one place in Waimea, the heart of the Big Island's agricultural district, and now has five restaurants and cafes scattered over three islands.

Merriman is the glue that holds together this new scene. He now has a steady supply of almost everything he could want, but when he started 25 years ago, he had to place classified ads asking local growers to sell him the fruits and vegetables he needed.

"Originally we really had to go out and encourage people to grow for us," he says. "Even into the '90s, we were a kind of a banana republic — in Hawaii most of the farmland was taken up by sugar cane and a little bit of pineapple grown for export.

"So our timing kind of worked perfectly. The sugar market was going down, and that made land available for farmers to come in and grow crops that hadn't been done before. At the same time, tourism was on the increase, so there was a market that was willing to pay a little more for higher-quality stuff."

He wasn't trying to change the world, he insists, although that's what happened.

"When I started I wasn't altruistic about it at all," Merriman says. "I wanted to serve great-tasting food. But as it evolved I did become a little more altruistic. You can't spend time with these farmers and go out to their fields without realizing how important it is to help them perpetuate what they are doing."

One of Merriman's favorite suppliers and a poster child for agricultural tourism is Kahua Farms, a fourth-generation livestock operation just outside Waimea. The 8,500-acre spread, operated by Tim Richards, hosts about 10,000 visitors a year — more than one tourist for every head of cattle and sheep it runs.

Richards and his father, Monty, are the models of modern ag, using state-of-the-art grazing rotations to reduce soil erosion and a wind turbine to generate most of the electricity for the ranch and the village of workers that support it.

Besides cattle and sheep ranching, Kahua Farms offers horseback tours of its lovely, hilly property, which sprawls along the slopes of Mauna Loa from mountainside rain forest to the ocean. There are all-terrain vehicle tours too and a site for corporate team-building exercises. The ranch also works with a tour operator to host regular barbecues, the visitors coming and going on one bus to minimize the impact.

None of these things adds substantially to the bottom line, Richards says, but all of it helps. Perhaps as important, it gives him a platform.

"Agricultural tourism gives me an opportunity to get up on my soap box and talk about ranch management and watershed management," says Richards, the president of the Hawaii Cattlemen's Council. "And then when they're back home and someone is talking about those evil farmers and ranchers, they can say, 'Well, you know, I talked to this guy in Hawaii and maybe they're not all so bad.' They can see that ranchers are not the ogres we're made out to be."

Steelgrass Farm on Kauai is another ag overachiever, although of a very different sort. Steelgrass, founded by brother and sister Will and Emily Lydgate, is ostensibly a cacao farm — the family is growing enough cacao to distribute the trees to farmers across the island in order to start a single-origin chocolate to be marketed with all the cachet brought by the name Kauai.

They're just about ready with that, but meanwhile, the Lydgates, fifth-generation Hawaiians, offer an entertaining tour of the farm. Besides the oddly beautiful cacao fruit — it looks like a huge, overinflated football in bright, glossy colors ranging from green to golden — the spunky tour guides also give an introduction to the tropical fruits of the island as well as to how cacao is grown and made into chocolate (including a tasting).

A gift shop sells chocolates, and visitors can rent one of two cottages and perhaps even avail themselves of a recording studio. It is used for recording music (acts as varied as gospel's Dixie Hummingbirds, ukulele sensation Jake Shimabukuro and background music for yoga classes). It's also done duty as a spot for voice-over work: Actors Ben Stiller and Jack Black have recorded parts of movies here.

Not all farm tours are as down-home. On Friday mornings, you can get a terrific glimpse of what might be the future of food at a sprawling project called the National Energy Laboratory of Hawaii in the lava fields just outside the Kona airport on the Big Island. Here, an experiment designed to generate electricity by using the temperature difference between cold, deep ocean water and warm shore water is paying unexpected dividends.

Although the power-generation part of the project is still a work in progress, for a couple of years the Big Island Abalone Corp. has been raising abalone — at least 60 tons a year, with a goal of 100 tons — and the red seaweed on which it feeds using an ingenious system based on the nutrient-rich cold water.

The NELHA site includes aquaculture start-ups growing lobster and kampachi, as well as companies making sea salt and desalinating ocean water for bottled water.

Or you could just go to a farmers market. They're so popular on Kauai that the audio tour on the GPS in my rental car listed them by day of the week.

The Hanalei market on Kauai is an ideal place to start. Its carefully selected assortment of farmers, artisan food makers and craftspeople also contribute to a good cause.

The lovely green valley the market inhabits once was slated to be turned into a golf course. Locals banded together to create the Waipa Foundation, a nonprofit group dedicated to restoring the 1,600-acre watershed and fostering community through traditional agriculture. That's the organization that sponsors the market and benefits from it.

Just think about all the good you could be doing by scarfing down a couple of pounds of mangosteens.