(Reuters) - Amazon.com Inc AMZN.O on Thursday said its sales surged over the summer and profit trounced expectations, as shoppers jumped at "Prime Day" promotions on its website and bought groceries at its newly acquired chain of Whole Foods Market stores.

Shares rose more than 7 percent in after-hours trade.

Amazon is winning business from older, big box rivals by delivering virtually any product to customers at a low cost, and at times faster than it takes to buy goods from a physical store. It acquired Whole Foods for $13.7 billion in August to help it deliver groceries to shoppers’ doorsteps.

Amazon’s results defied expectations that it would invest nearly all of its earnings into new areas as it has in the past. The world’s largest online retailer said net income rose to $256 million, or 52 cents per share in the quarter ended Sept. 30. Analysts on average were expecting 3 cents per share, according to Thomson Reuters I/B/E/S.

“This company has finally gotten itself to the point where it can sustain its spending growth and still leave some crumbs for shareholders,” said Wedbush Securities analyst Michael Pachter.

Prime Day, a summer marketing event Amazon has created to replicate the shopping frenzy that is more typical of the winter holiday season, helped boost sales.

Revenue rose 34 percent to $43.7 billion in the third quarter, including $1.3 billion in sales from Whole Foods. Analysts had expected $42.1 billion.

“There’ll be a lot of integration,” Amazon’s Chief Financial Officer Brian Olsavsky said on a call with analysts, citing how Amazon’s two-hour delivery service Prime Now could work with Whole Foods, for instance.

“We think we’ll also be developing new store formats,” he said.

FILE PHOTO - The logo of Amazon is seen at the company logistics center in Lauwin-Planque, northern France, February 20, 2017. REUTERS/Pascal Rossignol/File Photo

In a first, Amazon broke out sales for its online retail business and for its physical bookstores and Whole Foods locations. Revenue from its online stores jumped 22 percent to $26.4 billion, the fastest growth Amazon has seen in the segment in more than a year.

Key to its success has been signing more people up for Amazon Prime, its fast-shipping and video-streaming club, whose members tend to buy more from the company. Revenue from subscription fees such as Prime grew 59 percent to $2.4 billion.

And Amazon Web Services (AWS), which handles data and computing for large enterprises, saw its profit margin expand from the previous quarter. It posted a 41.9 percent rise in sales to $4.58 billion, beating the average estimate of $4.52 billion, according to analytics firm FactSet.

“They are firing on all cylinders. The machine is churning,” Benchmark Co analyst Daniel Kurnos said.

STILL BETTING ON HOLLYWOOD

Amazon shares have a high valuation, with a price-to-earnings ratio more than eight times that of cloud-computing rival Microsoft Corp MSFT.O, for instance.

Unlike peers, Amazon runs on razor-thin profit margins because it sinks most of its profit back into its business.

This quarter, which includes the shopping holiday Black Friday, Amazon said it expects operating profit between $300 million and $1.65 billion. Analysts were expecting $930.78 million, according to Thomson Reuters I/B/E/S.

Amazon’s profit is going toward a dizzying number of investments: warehouses for faster shipping, data centers for AWS, and a 77 percent uptick in employees last quarter, including Whole Foods workers.

The company plans to spend more on video content next year as well, Olsavsky said. Analysts estimate Amazon will have spent $4.5 billion this year.

The commitment to content comes after Amazon Studios chief Roy Price resigned last week, and other top studio hands left the company.

It is unclear what impact the shakeup may have on Amazon's ability to secure video that competes with Netflix Inc NFLX.O for viewers' attention.

The company’s shares, which closed down 0.05 percent on Thursday, rose about 7.5 percent to $1,046 in after-hours trading following the earnings statement. They had gained about 30 percent this year.