For years, bears argued that Amazon (NASDAQ:AMZN), while it could certainly grow, would never make a profit. The company allegedly sold items below cost and would never be able to raise prices to generate real earnings. After all, retail was full of big, low-cost competition, most notably Walmart (NYSE:WMT).

Oh, how times have changed.

Mind you, this is not a story about Amazon's cloud computing division, Amazon Web Services, which generated a staggering 31% operating margin last quarter. This is about the North American e-commerce business, which posted a 5.9% operating margin in the third quarter, up from roughly breakeven a year ago.

In fact, that operating margin is now greater than Walmart's. While Walmart has never generated very high margins due to its low-cost philosophy, it had always historically trounced Amazon in this department. But not anymore. 

So how did Amazon manage to pull this off?

A bearded man wearing a blue shirt and looking surprised

Image source: Getty Images.

Prime, ads, fulfillment

One of the ways in which Amazon added margin was by hiking the price of the Amazon Prime subscription service, which gives customers free two-day shipping on many items, exclusive video content, Whole Foods discounts, and a host of other benefits.

Amazon hiked Prime's annual price tag from $99 to $119 back in February of this year. With roughly 100 million Prime members, that means another $2 billion would fall to Amazon's bottom line, or about $500 million per quarter. That $500 million would account for approximately 25% of the roughly $2 billion in operating income for the North America segment last quarter.

In addition, Amazon's online advertising business is growing by leaps and bounds. As many social media investors know, internet advertising can be very profitable. Amazon accounts for ad sales in its "other" revenue category.

That category grew by about $1 billion from the year-ago quarter. Since advertising on Amazon properties is likely a high-margin business, I estimate that also contributed roughly $500 million (or more) to the North American bottom line.

While you may say, "Well sure, advertising is nice, but it isn't related to e-commerce," I'd beg to differ. Retailers like Walmart have always negotiated hard with vendors for prime shelf space or in-store promotions. That may not show up as revenue, but it would lower Walmart's cost of goods. This advertising platform is another advantage of the online-only e-commerce store Amazon has built. 

Finally, Amazon is getting more and more efficiencies out of its industry-leading fulfillment and distribution network. In 2016 and 2017, the company grew its fulfillment warehouse capacity by over 30%, while this year the company is only growing that capacity by about 15%, according to management.

That means Amazon's North American sales growth of 35% is significantly outpacing investment in warehouses. In addition, more and more of that warehouse capacity is going toward Amazon's third-party Fulfillment by Amazon business. That's a higher-margin business, because Amazon doesn't actually hold its own inventory, instead taking fees from third-party sellers. Last quarter, the third-party business grew 32%, a higher rate than the 11% growth in direct online sales.

With a higher percentage of third-party sales happening over a more fixed network, investors are now seeing the operating leverage inherent in Amazon's business model.

The times, they are a-changin'

For Walmart, it's the opposite case. In early 2016, Walmart purchased, making a full-court press to try to catch up to Amazon in e-commerce. In part, that's contributed to Walmart's operating margin deteriorating from 5% in 2015 to 4.1% last year, even as revenue grew.

Of course, Walmart has been able to grow revenue from e-commerce over the past year. But while revenue is great, profits today and in the future are better. Perhaps that's what Warren Buffett saw back in 2016 when he sold his Walmart stake. 

Amazon gets physical

Meanwhile, Amazon is not only becoming more profitable, it's now encroaching on Walmart's turf. The company unveiled its "4-Star" physical store in New York City last quarter, featuring items with a four-star and above rating on the e-commerce site. In addition, the company opened up five cashier-less Amazon Go stores across Seattle, Chicago, and San Francisco in the third quarter, with a plan for many more to come.

While investors like to point to the profits companies are currently making, one should always look at the bigger strategy -- especially when it comes to high-growth tech companies. If you had eschewed Amazon for years because it "didn't make money," you would have missed out on the recent progress. While, the shares sold off after its recent earnings report, Amazon is still up over 30% year to date, while Walmart is flat on the year.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.