Supervalu Inc., a pioneer in the Midwest grocery business that stumbled when it tried to run one of the nation’s largest store chains, agreed to be sold Thursday to an organic foods specialist in a $2.9 billion deal that brings new uncertainty for Cub Foods, Minnesota’s largest grocery operation.

United Natural Foods Inc., a Providence, R.I., firm that is the largest distributor to Whole Foods Market and other natural foods stores, offered to buy Eden Prairie-based Supervalu at a price well above its recent stock trading value. It then laid out plans to sell Cub and the handful of other grocery chains that provide about one-third of Supervalu’s revenue.

United Natural Foods will keep Supervalu’s wholesale business, which distributes goods to more than 3,300 groceries in about 40 states and employs more than 15,000 people. That business dates to the 1800s and remained the big profit generator through Supervalu’s difficult ownership of the Albertsons retail chain, which it sold in 2013.

For shoppers in the Twin Cities and towns around Minnesota, Thursday’s deal raises the prospect that Cub’s 78 stores will be divvied up among other chains, with some locations possibly closing. Mark Gross, chief executive of Supervalu, said recent improvements to Cub have helped the chain regain some ground it lost to competitors earlier this decade.

“I think [Cub] has got a great future, whoever owns it,” Gross told investors on a conference call.

Supervalu’s finances, including its ability to invest in Cub and other grocery operations, were hobbled in the past decade after its $12 billion purchase of most of the assets of Albertsons, more than 1,100 stores that it acquired chiefly with debt in early 2006. When recession came in 2008, Supervalu was doubly squeezed by thrifty customers’ migration to discounters like Walmart and the burden of making payments on billions of dollars in debt.

The company had trouble maintaining the investments necessary to compete in the low-margin grocery business and, in 2013, sold most of the Albertsons chain to an investment firm. Executives refocused the firm on grocery wholesale distribution.

“When the market leader is mediocre, it invites competition,” said David Livingston, supermarket analyst at DJL Research in Milwaukee. “Supervalu wasn’t putting a lot of money into its stores to keep them inviting.”

In more recent years Supervalu has tried to change that, adding new Cub stores in Blaine and Oakdale and remodeling nearly 30 of its Twin Cities locations. One new location is under construction, an urban concept store near 46th and Hiawatha in Minneapolis.

Last year, Supervalu hired Anne Dament, the former grocery chief at Target Corp., to freshen up its retail offerings as the vice president of retail and private brands. Her signature addition, Quick & Easy meals, has seen double-digit growth since its introduction.

“Our traffic and sales growth at Cub are stronger than we’ve seen for a very long time,” she said Wednesday at Supervalu’s annual expo for wholesale customers and vendors. Under Dament’s leadership, Cub’s signature stores, such as one in Stillwater, added popcorn stations, a juice bar, a coffee bar cafe and a revamped produce department.

Cub, which is celebrating its 50th anniversary this year, drove the superstore concept in Minnesota’s grocery scene in the 1980s. It once commanded a staggering 40 percent share of grocery purchases in the metro area, but that has slipped in recent years to around 25 percent, according to surveys by Metro Market Studies and Chain Store Guides.

United Natural Foods Chief Executive Steven Spinner said it will sell the Supervalu retail chains “in a thoughtful and economically driven manner.” He said that it will not always insist that the firms that buy the Supervalu chains remain customers of Supervalu’s wholesale businesses, as the groceries are now.

“Where appropriate, we will separate supply agreements from the sale of the banner in order to more expeditiously move this strategy forward,” Spinner said.

Analysts say Hy-Vee, Kroger and Albertsons are potential buyers for Cub and Supervalu’s other retail operations, which include the eight-unit Hornbacher’s chain in the Fargo-Moorhead market, 52-store Shoppers chain in Washington-Baltimore and Shop ’n Save and Farm Fresh chains in the St. Louis area and the mid-Atlantic states.

Other candidates are Ahold USA, a unit of a Dutch retailer that has purchased the Food Lion and Giant chains; and Overwaitea, a Canadian grocery firm, said Burt Flickinger of Strategic Resource Group, a New York consulting firm. He said that he doesn’t expect a large number of Cub stores to close. “It’s a possibility they will be bought on a bundled basis and kept open,” he said.

Hy-Vee announced last week that it purchased a Cub store in Plymouth on County Road 24 that closed two weeks ago. It plans to remodel the store and reopen it in the fall. Hy-Vee spokeswoman Tina Potthoff would not comment on any other locations. “We don’t have anything else to report on acquiring existing buildings in the Twin Cities at this time,” she said in an e-mail.

Livingston said he believes the Cub chain will be split among several buyers, with the best performers attracting the most attention from the industry’s leading firms and others. “Kroger doesn’t like fixer-uppers,” he said. “Albertsons will be looking to pick them up cheap.”

After Kroger, the nation’s largest grocery company, purchased nearly 100 Roundy’s stores in Wisconsin in 2015, it closed about two dozen, including 12 in Milwaukee.

Supervalu’s deal with United Natural Foods came just three weeks before Supervalu shareholders were to vote on whether to replace the company’s board of directors with a slate of candidates backed by an activist investor who took a stake in it about a year ago. The activist, an investment firm called Blackwells Capital LLC in New York, advocated the sale of Supervalu’s stores, among other steps to lift its stock price.

Blackwells had no immediate comment on Supervalu’s sale to United Natural Foods, a spokeswoman for the firm said Thursday.