Just when it appeared the Twin Cities supermarket scene was shrinking, it started growing — in a big way.

When the Twin Cities last year lost Rainbow Foods, a major supermarket in the area since 1983, shoppers grumbled about the expectation of higher prices in the face of less competition.

Half of Rainbow’s 27 stores closed while others went to existing players. But more than 20 new stores are expected to open in the next two years, including several from new entrants to the market, Hy-Vee and Fresh Thyme. The result: a frothy competition in prices and a race by existing store chains to remodel and expand offerings.

“This is a very competitive time in Twin Cities grocery,” said John Dean, a supermarket analyst for the Twin Cities market. “It’s more competitive than 10 years ago when Wal-Mart Supercenters, SuperTarget and Aldi started opening.”

The market has steadily piled on choice upon choice for consumers to savor — discounters such as SuperTarget, specialty markets such as Whole Foods, as well as pharmacies, dollar stores, and home delivery from online sites.

And consumers have a responded with a shift in loyalty. One in 10 Twin Cities shoppers now say they don’t have a primary supermarket, triple the level who said that in 2012, according to research by the Food Marketing Institute.

Penny Swanson of Forest Lake said she’s happy about the new competition, “cherry picking” at multiple stores. “I still shop Cub, but I like Wal-Mart, Festival and Hy-Vee too,” she said as she shopped at Wal-Mart in Stillwater on Wednesday. “I go to Wal-Mart for price and Hy-Vee for variety and organics.”

“Consumers benefit with better selection and lower prices,” said Jennifer Bartashus, a retail analyst for Bloomberg Intelligence. “Hy-Vee could be really disruptive in this market.”

That spells new challenges for Cub, which has 68 stores in the Twin Cities and the largest market share, measured at 24.2 percent by Nielsen and 18 percent by Chain Store Guide. David Livingston, a Wisconsin-based supermarket analyst, said a big player like Cub is “the easiest to steal customers from.”

Cub executives were not available to comment for this story.

Hy-Vee, the Des Moines-based chain that dominates Iowa and extends through much of the Midwest, is entering the Twin Cities with very large stores that most closely rival Cub’s. In the most direct response by Cub so far, the company is moving its Oakdale store to a larger building nearby that will make it virtually the same size as the new Hy-Vee in that St. Paul suburb.

Cub Foods has been advertising a new slate of price cuts. But it’s difficult for multiple metro stores to expand, remodel or cut prices in a significant way, said Livingston.

Hy-Vee’s stores include a full-service Market Grille with a bar, a pharmacy with a drive-up window, an in-store health clinic, a dietitian and wellness department, floral shop, made-to-order salad and sushi bars, liquor store, charcuterie, a HealthMarket section with local and organic products, Starbucks, mother’s rooms and a soon-to-arrive post office substation.

Sharon Wong of Blaine said Hy-Vee is her new favorite. “It’s a beautiful store, the restaurant is great, and the customer service is better,” she said. “And they bag your groceries too.”

Hy-Vee is attempting to find a way to stop consumers from segmenting their grocery shopping at multiple stores. By adding large selections of gourmet offerings, organics, and grab-and-go freshly made meals, as well as gas stations, liquor stores, and wellness programs in one location, the retailer hopes to grab more consumer dollars at one convenient location.

Still, for nearly all consumers, price remains a big factor in choosing a supermarket. Consumers may be willing to do more impulse buying now than during the recession, Bartashus said, but a large number are still very price conscious. Swanson, who said she checks prices carefully, still finds Wal-Mart’s grocery prices the lowest in the Twin Cities, handily beating Hy-Vee.

Dave Crowley of Shakopee, who has shopped at the Hy-Vee in New Hope multiple times, believes its prices are comparable to Cub’s. “Hy-Vee isn’t cheap, but the quality is excellent. It’s like being at Byerlys with Cub’s prices,” he said.

In the just-released issue of Twin Cities Consumers’ Checkbook magazine, the prices on a basket of 152 items were compared at local supermarket chains. Using Cub as a benchmark, Wal-Mart’s prices were 14 percent less, Target 11 percent less and Hy-Vee 4 percent. The stores that were more expensive than Cub: Festival at 12 percent higher, Lunds & Byerlys 20 percent more, Kowalski’s 24 percent more and Whole Foods 49 percent.

Comparisons for Costco, Sam’s Club, Trader Joe’s and Aldi were less precise because product sizes differed and private labels were more prevalent. Checkbook found that Costco’s and Sam’s were 25 or 26 percent lower than Cub.

No-frills Aldi, where customers put down a returnable quarter deposit for a cart and pay extra for bags, was found to have prices that were 36 percent less than Cub. Aldi has 31 metro stores, with two more opening in Blaine and Medina this year. Four to five more will open next year.

Prices at Trader Joe’s, a popular choice for its specialty items and organics, were 4 percent more than at Cub. The California-based chain currently has seven stores in the Twin Cities. A new store in downtown Minneapolis will open in 2017.

In terms of store quality, Checkbook judged the chains on produce, meat, variety, speed of checkout, staff helpfulness and parking. Kowalski’s and Lunds & Byerlys received Checkbook’s highest scores for quality among the chains, but co-ops such as Seward Community in Minneapolis and Mississippi Market in St. Paul scored even higher.

With Trader Joe’s, Coborn’s, Cub, Whole Foods and Aldi adding new stores, price and service competition appears likely to grow in the metro area.

Checkbook said the Twin Cities has the lowest overall grocery prices of the seven metro areas that it surveys. “Supermarket prices in the Twin Cities are about 5 to 11 percent less than any other market we survey,” said Kevin Brasler, executive editor of Washington, D.C.-based Checkbook.

For a breakdown of Checkbook’s analysis of Twin Cities supermarkets, go to www.checkbook.org/startribune/supermarkets.