Amazon reported a surprise loss of $7 million, or 2 cents per share, for the three months through June.
Wall Street analysts had expected Amazon(AMZN) to earn 5 cents per share in the second quarter.
The loss comes despite the fact that sales at the company continues to soar, rising 22% to $15.7 billion from the same quarter last year. The growth in sales was just shy of analysts' expectations of $15.73 billion.
Amazon's loss stems from costly investments that the company is making. CEO Jeff Bezos' long-term vision for Amazon is to steer it into digital products like the Kindle tablet devices and digital content for its Amazon Prime video streaming service.
"This past quarter, our top 10 selling items worldwide were all digital products -- Kindles, Kindle Fire HDs, accessories and digital content," Bezos said in a prepared release.
Amazon struck a deal with Viacom in June that gives it exclusive rights to stream TV shows from Nickelodeon, MTV and Comedy Central on its Amazon Prime service.
The company jumped on the opportunity soon after rival Netflix(NFLX) let its own contract with Viacom(VIA) expire. Netflix currently accounts for 89% of all subscription-based video streams, while Amazon Prime accounts for just 2%, according to the NPD Group.
Speaking with investors after releasing results, Amazon's chief financial officer Tom Szkutak said the site is acquiring new premium members because of its video content.
Amazon has also been spending heavily on making its web services business more secure. Known as cloud services, it is a fast-growing part of the company, where it rents out vast amounts of data storage space to other companies via the Internet.
Amazon shares dropped by almost 2% in after hours trading.