Michael Seto/Business Insider
The ecommerce giant reported a net income of $92 million, or 19 cents a share. Analysts were expecting Amazon to post a loss of 14 cents a share. At this time last year, Amazon lost 27 cents per share.
Amazon's stock was up more than 18 percent at $572.57 in after-hours trading.
How did Amazon pull off the big bottom line surpise?
Stronger than expected revenue across all of Amazon's businesses helped. But Raymond Baird analyst Colin Sebastian said that the strength in two businesses with particularly strong profit margins were the real heroes during the second quarter.
"Gross margins were well above expectations, that reflects more services revenues. That means AWS and third-party marketplace, those have much higher gross margins," said Sebastian.
AWS is Amazon's cloud computing business, which competes with Google and Microsoft. Third-party marketplace is Amazon's business selling other retailers' goods on its website.
It also appears there's "some element of expense control" at play during Amazon's recent quarter, Sebastian noted.
But investors should not necessarily get used to a profitable Amazon, he noted.
"The key question is are they actually harvesting earnings now, or is it more just a pause in investment spending?"
Disclosure: Jeff Bezos is an investor in Business Insider through hispersonal investment company Bezos Expeditions.