document: The online retail giant reported a $92m profit compared to a $126m loss for the same period a year ago.
  Sales also rose 20% to $23.2bn in the second quarter to the end of June, boosted by strong growth in the US.
  Its shares, which fell 1.3% during the day, leapt 18.5% to $571.24 a share in after-hours trading on Wall Street.
  The firm was also upbeat on its prospects for the current third quarter, forecasting sales would grow between 13% and 24% compared to last year, much higher than analysts had predicted.
  Sales in North America rose 25.5% to $13.8bn in the second quarter, driven by purchases of electronic goods and general merchandise, helping to drive the strong performance.
  Its cloud computing division, Amazon Web Services, also made a contribution, with sales up 81% compared to the same quarter last year.
  It said its widely promoted "Prime Day" on 15th July - which offered special deals to customers who signed up to its fast delivery service - had been a success with more new members trying it globally than any other day in the firm's history.
  Amazon founder and chief executive Jeff Bezos credited hard work for the results: "The teams at Amazon have been working hard for customers," he said.
  Throughout its history, Amazon's revenue has climbed while its profit has hovered around or below zero.
  On Thursday evening, the e-commerce company reported a profit.
  As customers in North America bought electronics and others products, sales in its biggest market rose more than 25% compared to last year.
  And if you thought Microsoft's cloud computing business did well, then take a look at Amazon web services which includes its cloud business - revenue soared more than 80 percent.
  The only slight negative was that sales growth outside the US wasn't nearly as impressive.
  Still after years of ploughing its cash into new technology , mostly aimed at making it easier and faster for customers to get what they want, the results are starting to pay off - at least in the eyes of Wall Street
summary: Amazon shares have surged more than 18% in after-hours trading after it reported a surprise profit and better-than-expected sales figures.