Amazon.com is buying Whole Foods for $13.7 billion, a deal that comes as the online retail giant makes a big bet on brick-and-mortar stores to get a bigger chunk of consumer spending.

The online juggernaut will gain 400-plus Whole Foods Market stores around the country — about 30 of which are in the Bay Area. Experts say this is a groundbreaking move that will likely upend the grocery industry, putting major pressure on traditional stores and rival online-delivery services to keep up.

“The 40,000-square-foot market as we know it is a dinosaur,” said Phil Lempert, the food trends editor for NBC’s “Today” show who’s known as the Supermarket Guru. “This is going to be a great shot in the arm for the industry.”

Whole Foods Market will continue to operate stores under that name. John Mackey, co-founder of the chain based in Austin, Texas, will remain as CEO of the company.

Whole Foods caters to higher-income customers, a demographic that matches subscribers to Amazon’s Prime membership program. Experts say this acquisition is a smart way to expand Amazon’s physical footprint and enter the hypercompetitive grocery industry. But critics worry it gives the online behemoth too much control of a burgeoning sector. The market for Internet food sales could grow fivefold to $100 billion by 2025, according to the Food Marketing Institute and Nielsen Co.

Amazon has been in the grocery delivery service for years. AmazonFresh, launched a decade ago as a test in a single city near Seattle, offers same-day delivery in a dozen U.S. cities and four cities overseas with a limited selection of groceries.

But its brick-and-mortar experiments have been slow to spread beyond a handful of outposts. It has a single Amazon Go store, a basics-only grocery with no checkout line, and two AmazonFresh Pickup locations where online purchases are loaded into customers’ cars. There are eight Amazon bookstores in California, Illinois, Massachusetts, New Jersey, New York, Oregon and Washington. The company will soon open another bookstore in Walnut Creek.

MBA BY THE BAY: See how an MBA could change your life with SFGATE's interactive directory of Bay Area programs.

Amazon has seen setbacks in trying to bring grocery stores to the Bay Area. Sunnyvale officials approved plans for a store last fall, but the project shows few signs of moving forward. The developer of a San Carlos location put the application on hold after seeing neighborhood opposition over truck deliveries. Buying Whole Foods gives Amazon stores from coast to coast, and a real estate team experienced in getting approval for stores.

This deal is also seen as a win for Whole Foods, which recently announced a board shakeup and a cost-cutting plan amid falling sales. The chain, sometimes called “Whole Paycheck” by customers, is known for pricey fare. It has struggled to compete with cheaper sellers of organic food like Trader Joe’s. Its new 365 chain, with locations planned for Oakland, San Francisco and Concord, emphasizes lower prices.

The biggest loser in this deal could be Instacart, which sends shoppers into Whole Foods stores to pick and deliver groceries for customers.

That’s for two reasons, said Arun Sundararajan, a New York University business professor: It will lose Whole Foods as a grocery partner, and it is likely that Amazon will compete directly with Instacart by offering its own home deliveries of Whole Foods groceries. (A person familiar with Instacart’s relationship with Whole Foods says the companies have a multiyear, exclusive contract.)

As Amazon injects its logistical wizardry into Whole Foods, each store “will serve the dual purpose of being a retail destination and also an intelligent local warehouse,” he said.

While Instacart, Uber and Postmates in San Francisco and Palo Alto’s DoorDash all have expertise in local last-minute delivery, their operations “pale in comparison to the immense organizational expertise Amazon has in delivering to households,” Sundararajan said.

For artisanal food vendors and upstart consumer brands, Whole Foods has also been a place to launch products and gain exposure to a mainstream market. Rather than displace them with mass-market brands, Amazon could very well tap those suppliers to boost its offerings.

“Amazon is great,” said Kara Goldin, CEO of Hint Inc., which sells flavored waters through Whole Foods and Amazon as well as directly to consumers online. “They deliver product quickly and effectively and Whole Foods will give them access to more food product and local delivery.”

Goldin said the real key to the deal was Whole Foods’ customer data, which Amazon could exploit.

Bob Hetu, a retail-industry research director for Gartner, said Whole Foods now has the ability to make use of Amazon’s technology and cost-cutting mind-set. That may help the store drive prices down and appeal to a wider demographic.

Amazon “will likely look at the Whole Foods model and see where it’s broken — pricing, inefficiencies on the inventory management side,” Hetu said. “They could fix that stuff, and see where they can add automation and where the human element is required.”

Shares of Whole Foods and Amazon both jumped on the announcement. The deal is expected to close by the end of the year.

While experts and investors largely view the deal as positive for the two companies, they point out how competitors and partners could be hurt. It could give Amazon, already a dominant player in online sales of books, electronics and other goods, an edge in food delivery as well. Whole Foods had 1.2 percent of the food and grocery market in 2016, according to GlobalData Retail, and Amazon had 0.19 percent.

“Amazon’s acquisition of Whole Foods raises significant anticompetitive issues that should be deeply concerning to federal antitrust regulators and the public,” said the Institute for Local Self-Reliance, an advocacy group that focuses on community development and is a frequent critic of the online retailer. This deal “would give Amazon, which already sells more clothing, books, toys and consumer electronics than any other retailer, a substantial share of an even bigger consumer goods category, groceries.”

“I am concerned about what this deal means for suppliers and neighborhood grocery stores,” said Rep. Ro Khanna, D-Fremont, in a statement. “The Justice Department and Federal Trade Commission must undertake a review that considers not just the merger’s impact on prices, but also the impact on jobs and wages. We need to reorient antitrust policy to factor in the harm that economic concentration causes for American workers.”

“This will cause some consolidation in the retail market, as it tries to figure out how to confront this shift,” Hetu said. “But it all depends on how well (Amazon and Whole Foods) manages this connection. ... We’ve seen a lot of these visionary mergers go bad before.”

Chronicle staff writer Carolyn Said contributed to this report.

Trisha Thadani is a San Francisco Chronicle staff writer. Email: tthadani@sfchronicle.com Twitter: @TrishaThadani