They started in the late 19th century as big batches of sandwiches, prepared by volunteers in church basements and hauled to the Minnesota State Fair in horse-drawn carts.

Back when the Minnesotans getting together at the Great Minnesota Get-Together were primarily farm families crossing the state for a multiday visit, church dining halls played a central role. When those folks took a break from showing their prize pigs or checking out the farm equipment on Machinery Hill, they wanted hearty, square meals. The dining halls filled that need, eventually opening up kitchens right on the fairgrounds and serving up meatballs, gravy-slathered sandwiches, Swedish egg coffee, homemade pie.

At their peak in the 1930s and ‘40s, there were more than 50 church dining halls on the fairgrounds, said Dennis Larson, who’s in charge of approving food vendors at the fair.

Now just two remain: the 116-year-old hall operated by Hamline United Methodist Church in St. Paul, and the smaller hall run by Salem Lutheran Church in Minneapolis, a relative newbie at “only” 64. (A third dining hall is run by Order of the Eastern Star, a fraternal organization.)

“They’re a big part of who we were, but no longer who we are, I guess,” Larson said.

Once upon a time, 80 percent of fairgoers worked in agriculture. Nowadays, it’s fewer than 2 percent, Larson said. Today’s citified visitors don’t waste time and appetite on heavy sit-down meals — they graze on deep-fried and chocolate-dipped oddities improbably impaled on wood.

“My folks, who are in their 80s, always go” to the dining halls, Larson said. (So do many fair employees, who over the 12-day run crave at least the occasional balanced meal.) But for younger visitors, “it’s not a part of our culture,” he said. “The next generation was raised on the corn dogs and food on a stick … quick food they can eat and enjoy while they’re walking around the fair.”

Meanwhile, stricter health codes have made dining halls — once a substantial source of church revenue — less profitable, Larson said. The halls are required to meet restaurant-level standards for new equipment, which means a big expense for establishments open only 12 days a year.

“A couple of them have said, ‘We’re one dishwasher away from making a profit this year,’” Larson said. Even with volunteer workers, profits may dwindle to the point that church committees ask, “Is this the best use of our volunteers?”

For Salem Lutheran Church, though, the answer is still an emphatic “yes.”

“Our biggest thing we’ve got going for us is that we’re 100 percent all volunteers,” said Mario Carrillo, the dining hall’s day manager.

Not only are Salem’s parishioners supportive of the project, but the hall lures volunteers from other churches to help fill its 50 shifts a day. “It’s just unbelievable the amount of people we have coming out to help,” Carrillo said.

Hamline Dining Hall pays its teenage staffers, giving them job experience and a chance to work alongside older volunteers whose compensation is a free meal and a gate ticket, said Jan Bajuniemi, treasurer of the Hamline hall’s committee. “That’s part of I guess what you’d call our goal, to have a multi-age experience.”

Just because dining halls have declined in popularity doesn’t mean their food is unappealing or out of date. Enthusiasts return every year to sample favorites like meatballs and Swedish coffee (with an egg mixed into the grounds), dished up on real (not paper) plates and poured into real cups.

The glossy gourmet magazine Saveur heaped praise on dining-hall cuisine last summer, in a four-page feature on foods of the Minnesota State Fair. Well-known food writers Jane and Michael Stern enticingly described Hamline’s famous ham loaf — “coarsely ground and seasoned ham served in thick, pink slices under a spill of brown sugar-mustard-vinegar syrup” — and ran an appetizing photo of the loaf on a plate with side dishes.

Bajuniemi isn’t certain when the ham-loaf tradition got started. “People either love it or wouldn’t touch it,” she said. She noted that a ham-loaf slider introduced last year got “an interesting response.”

These quaint halls can even be a surprising source of culinary innovations. Hamline has an item on the fair’s celebrated new foods list this year, developed in cooperation with Minnesota-based Izzy’s Ice Cream and combining two classic fair delicacies: Mini Donut Batter Crunch ice cream. (A church volunteer’s initial suggestion of cheese-curd ice cream got the thumbs down from Izzy’s co-owner Jeff Sommers, Bajuniemi said.)

Salem, for its part, has developed such popular novelties as Thanksgiving in a Bowl (turkey, dressing, potatoes, corn, cranberries, gravy) and the Meatball Sundae (meatballs, mashed potatoes, gravy).

“We try to keep it fun, and really entertaining, because what does everybody go out to the fair for?” Carrillo said.

They may be the last holdouts, but neither church has plans to shut down anytime soon, Carrillo and Bajuniemi said. Though volunteers are always exhausted at the end of each fair, by the next year “everybody’s ready to give it another shot,” said Bajuniemi, who like a number of her colleagues has more than 50 years of experience working in dining-hall kitchens.

Even with their golden age behind them, dining halls still serve a valuable function amid the fair’s noise and chaos, Bajuniemi said. “I think what we still offer is a meal at a table, a chance to get out of the crush of the crowds, sit down and take it easy and enjoy the food on the plate.”