Amazon is buying Whole Foods.

The online giant is buying the high-end grocer for $42 a share, valuing the company at $13.7 billion.

Shares of the grocer were trading at $33.06 a share before the deal was announced, so the deal represents a 27% premium on its closing price yesterday.

"Millions of people love Whole Foods Market because they offer the best natural and organic foods, and they make it fun to eat healthy," Amazon CEO Jeff Bezos said in a press release. "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."

The move comes after activist investor Jana Partners took an 8% stake in Whole Foods in April and pushed the company to look into strategic options including a sale.

In October, reports surfaced that Amazon was planning to build its own grocery stores. The company has built other physical retail locations for books.

"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," Whole Foods CEO John Mackey said in the release.

According to the release, Whole Foods will continue to operate under its own name and Mackey will stay on as CEO of the brand.

Interestingly, Mackey called activist Jana Partners "greedy bastards" in an interview released on Wednesday.

"These guys just want to sell us, because they think they can make forty or fifty percent in a short period of time," Mackey told Texas Monthly's Tom Foster. "They're greedy bastards, and they're putting a bunch of propaganda out there, trying to destroy my reputation and the reputation of Whole Foods, because it's in their self-interest to do so."

The deal will be financed partly through debt with Goldman Sachs and Bank of America Merrill Lynch funding the transaction.

Whole Foods would also pay a $400 million termination fee to Amazon if the grocer receives a better offer or the board of directors pulls the company out of the deal.

Following the news of the acquisition, Amazon shares were up just over 2% at $984.31 as of 9:24 a.m. ET. Whole Foods shares were up just over 27% to the $42.00 per share acquisition price.

This post originally appeared on Business Insider.