E-commerce giant Amazon said on Friday that it had agreed to buy Whole Foods, the upmarket grocery chain in a $13.7bn (£10.7bn) deal.

The US grocery market accounts for around $700 to $800bn in annual sales.

Amazon will acquire Whole Foods for $42 a share, a 27 percent premium on where the stock was trading just yesterday.

Although Amazon already has its own grocery delivery service Amazon Fresh, the move marks the online retailer’s ambitious push into traditional bricks-and-mortar territory.

The e-commerce giant has experimented with physical stores, but its scope so far has been limited.

It operates a small chain of book stores across the country and opened two drive-through click-and-collect grocery pickup locations in Seattle three months ago.

As well as expanding its footprint beyond the web, the agreement also allows Amazon to put pressure on some its biggest competitors such as Walmart, which currently has the largest share of the US food market.

The deal could be “transformative,” credit rating agency Moody’s lead retail analyst Charlie O’Shea said, “not just for food retail, but for retail in general.”

Founded in 1978 in Texas, Whole Foods is best known for its organic produce.

The grocer now boasts more than 460 stores across the US, Canada and the UK, and employs about 87,000 people.

“Millions of people love Whole Foods Market because they offer the best natural and organic foods, and they make it fun to eat healthy,” said Amazon’s founder and chief executive Jeff Bezos.

“Whole Foods Market has been satisfying, delighting and nourishing customers for nearly four decades – they’re doing an amazing job and we want that to continue,” he added.

3 Things That Will Change the World Today

Why Whole Foods needs to maximise its value

Whole Foods has been struggling to compete with other supermarket chains for the past two years.

Its same-store sales have fallen for seven consecutive quarters leading to dissatisfaction from its investors.

In April, one of Whole Foods’ biggest investors, the hedge fund Jana Partners said the grocer’s shares were undervalued, noting “chronic underperformance”.

In a bid to shore up support, the company appointed a new chief financial officer and new board members last month.

The takeover deal — the biggest in Amazon’s history — is expected to be completed in the second half of the year, pending approval by shareholders and anti-trust regulators, the BBC reported.

“This partnership presents an opportunity to maximize value for Whole Foods Market’s shareholders, while at the same time extending our mission and bringing the highest quality, experience, convenience and innovation to our customers,” said Whole Foods chairman John Mackey.

Mackey will continue in his position and Whole Foods’ headquarters will remain based in Austin, Texas.

Shares in Whole Foods soared almost 27 percent while Amazon climbed 3.4 percent when the deal was announced on Friday.

“There is an inherent logic in the move which, in our view, brings benefits to both businesses,” said Neil Saunders, managing director of GlobalData Retail.