Amazon.com Inc. said it would buy Whole Foods Market Inc. in a deal valued at about $13.7 billion, including debt.

The $42 per share offer represents a premium of 27 percent to the upmarket grocery chain's Thursday close.

Whole Foods shares were halted at $32.77 in premarket trading, while Amazon's shares were up 0.5 percent at $969.

"That was rumored, I totally dismissed it. Wow. Amazon can pour money into any investment and they don't need to make money. Investors are used to them not making money. It is $13.7 billion but it is still small relative to the size of the whole company," Chief Investment Officer of Solaris Asset Management Tim Ghriskey said.

Excluding debt, the deal is valued at $13.39 billion, based on 318.9 million diluted shares outstanding as of April 9.

The grocer will continue to operate stores under the Whole Foods Market brand, the companies said.

John Mackey will continue as chief executive of Whole Foods, and the company's headquarters will remain in Austin, Texas.

Amazon and Whole Foods expect to close the deal during the second half of 2017.