The Seattle-based company's net income totaled $513 million, or $1.07 per share, compared with a loss in the same period a year earlier. The average estimate of 14 analysts surveyed by Zacks Investment Research was for earnings of 61 cents per share.

In a statement, CEO Jeff Bezos said sales of Amazon devices such as the Echo smart speaker and the Fire TV stick were strong, although the company does not break out specific sales figures.

Amazon's cloud-based services, called Amazon Web Services, remained another bright spot, with revenue up 64 percent to $2.57 billion.