Amazon learns to stop worrying and love the profits.
Amazon posted a record profit in the quarter ending in June, marking its fifth consecutive profitable quarter. That's Amazon's longest period of profitability in four years, according to FactSet.
The e-commerce company earned $857 million in net income for the quarter, beating estimates and shattering the $92 million in profit it earned the same quarter a year earlier.
Amazon's (AMZN) streak of profitable quarters has catapulted its stock to all-time highs -- and helped founder and CEO Jeff Bezos overtake Warren Buffett this month to become the third richest person in the world.
The stock was up 1.5% in after hours trading.
The long period of profitability marks a bit of a departure for Amazon. Bezos has traditionally focused on reinvesting all (or almost all) profits back into big bets like fulfillment centers, hardware, video streaming and cloud computing.
Related: Every day is Prime Day for Jeff Bezos
When Amazon chooses to turn the knobs a little to the left and posts a slight profit, investors cheer. And when it (often) chooses to go into the red, all hell breaks loose.
On an earnings call with analysts, Amazon CFO Brian Olsavsky said the company continues to "invest heavily" in new areas like digital content. In fact, Amazon plans to double its investment in online video from a year ago, as it increasingly competes with the likes of Netflix (NFLX).
It's clear the big bets are paying off. Amazon Web Services, its cloud business, posted sales of $5.5 billion through the first six months of this year, which is already more than its sales for all of 2014.
Overall, Amazon sales topped $30 billion for the quarter, fueled by continued demand for online shopping. Last year, the company hit $100 billion in annual sales for the first time.
The e-commerce market is expected to grow by 13% in the U.S. this year to nearly $400 billion, and Amazon remains the dominant player, according to research firm eMarketer.
As James Cakmak, an analyst with Monness, Crespi, Hardt & Co, put it in an investor note this week, "There is perhaps no better secular growth story than Amazon in the Internet space."