Jim Young/Reuters

Twinkies and Ding Dongs are back from the dead.

Hostess Brands, the now bankrupt owner of the cream-filled confections, agreed on Tuesday to sell the snacks — along with Ho Hos, Sno Balls and Dolly Madison Zingers — to two investment firms with a shared history of corporate turnarounds.

The deal, worth $410 million, was struck nearly four months after the last Twinkie rolled off the baking lines.

Related Links Document: Hostess press release

When Hostess, unable to reach a deal with its bakers’ union, announced in November that it would wind down operations, it set off waves of nostalgia for a symbol of American junk food. As recently as Tuesday, sellers on eBay were seeking to fetch as much as $250,000 for two boxes of Twinkies.

The sale will mean that Twinkies, born more than 83 years ago in an Illinois industrial kitchen, will live on, having survived wars, recessions and the South Beach and Dukan diets.

The new owners will be Apollo Global Management and Metropoulos & Company, which owns Pabst Blue Ribbon and Vlasic pickles. C. Dean Metropoulos, the food industry veteran who leads the firm that bears his name, is expected to become the chief executive of the snack business.

The deal includes five Hostess factories, which the buyers hope to restart so to begin restocking shore shelves by the summer. And the new company will almost certainly feature the Hostess name.

“There’s a great consumer fan base that hasn’t declined,” Daren Metropoulos, one of Mr. Metropoulos’ sons and an executive at the family firm, said in an interview. “We saw a real opportunity to revitalize these brands, just with some T.L.C.”

That may come in the form of what the younger Mr. Metropoulos deemed “guerrilla marketing,” much as his firm has done with Pabst Blue Ribbon. Social media like Twitter are expected to play a big role going forward, he said, and comedian friends like Zach Galifianakis may be drafted as spokesmen. (Will Ferrell, for instance, has starred in commercials for Old Milwaukee beer, part of the Pabst family.)

The business’ new owners also hinted that Twinkies might find a home in a broader array of stores, including discount retailers like Dollar General. Healthier options, like 100-calorie snack packs, are also expected to make an appearance.

Yet the buyers are unlikely to rely as heavily on a unionized work force as the old Hostess did.

“We look forward to discussing opportunities for our members with new ownership, and add value to the revival of these products,” David Durkee, the president of the Bakery, Confectionery, Tobacco Workers and Grain Millers International Union, said in a statement.

Apollo and Metropoulos emerged from what at one point seemed like a crowded field of bankruptcy bidders for the brands. At one point, more than 100 parties had expressed interest in Twinkies, a group that included international food giants and private equity firms.

But by 5 p.m. Monday, the deadline for bids, the only qualified offer came from Apollo and Metropoulos. Advisers to Hostess canceled an auction scheduled for Wednesday morning and declared the two the winner.

“It’s not that we lacked interest,” Gregory F. Rayburn, the Hostess chief executive, said in an interview. “Other bidders felt that they could not top the price.”

The new owners bring significant food industry expertise to the deal.

C. Dean Metropoulos has worked side-by-side with private equity firms on his deals in the past. He oversaw several food transactions for the Dallas private equity firm Hicks Muse Tate & Furst, including International Home Foods, the parent of Bumble Bee Tuna and Chef Boyardee.

Mr. Metropoulos, who has a net worth of $1.2 billion, according to Forbes magazine, made a splash in 2010, when he acquired Pabst Blue Ribbon for $250 million. Pabst — known as P.B.R. among the beer-drinking crowd — has experienced a renaissance in recent years. Mr. Metropoulous’s sons, Evan and Daren, work alongside their father at the firm, based in Greenwich, Conn.

Still, reviving Twinkies and Ring Dings could be their highest profile turnaround.

As for Apollo, the private equity firm has deep experience with food-related investments, having previously owned stakes in the grocery-store chains Ralphs and Dominick’s.

Apollo currently holds a controlling stake in Sprouts, a large natural food store chain in the Western United States that, presumably, will not be selling Hostess snacks.

The sale is not done yet. It requires the approval of the federal bankruptcy judge overseeing the Chapter 11 case. A hearing has been tentatively scheduled for March 19.

Hostess is still selling its other remaining brands, including Drake’s snack cakes. Those auctions are expected to conclude by early next month.

Mr. Rayburn said that at some point, Hostess executives will celebrate by popping open a bottle of Champagne.

For his part, Daren Metropoulos said that he and his family would sample some new batches of Hostess product — “and probably crack open a cold P.B.R.”