Many investors may own Amazon (AMZN 0.29%) and Apple (AAPL -1.12%) in their portfolios but may have a difficult time choosing which stock is a better buy right now. These are both dominant businesses in their respective industries with great growth prospects, so either stock would make a fine addition to a well-diversified portfolio.

But this is certain: One of these stocks will outperform the other over the next five years. Let's review the strengths and opportunities for these companies to determine which one that is likely to be.

Amazon: The leader in e-commerce and cloud services

Amazon generates $538 billion of annual revenue, with 17% of that total coming from its cloud services unit Amazon Web Services. It benefits from diverse revenue streams and a large customer base that is attracted to a wide selection of merchandise, streaming entertainment, and other services.

Amazon faces an increasingly competitive e-commerce market, but it continues to grow online store sales by continuing to get faster in delivery with same-day and one-day shipping for more customers domestically. After sales slowed growth last year due to macroeconomic headwinds, Amazon has bounced back. Sales grew 11% year over year in the second quarter. Amazon is also improving efficiency across its fulfillment network, which led to operating profit more than doubling year over year.

Growth might be slowing as the company gets bigger, but Amazon's strength is a smooth, rising line in annual revenue. That reflects a lot of repeat purchases from an army of loyal Prime shoppers, in addition to recurring revenue from nonretail businesses, such as Amazon Web Services.

AMZN Revenue (TTM) Chart

AMZN Revenue (TTM) data by YCharts

Amazon may never grow at the high rates it did before the pandemic, when it saw over 20% growth per year. But it offers such a wide selection and fast delivery that it should continue to grow at double-digit rates for many more years. That's because there is still a very long runway of growth in the global e-commerce market that is worth trillions and continues to grow.

Even with Amazon's lead in e-commerce, investors should know that most of the company's revenue comes from nonretail services. Revenue from third-party fulfillment fees, subscription services, advertising, and cloud services totaled 56% of Amazon's business in the first half of 2023, and these revenue streams have been growing much faster than the retail side in recent years. 

These nonretail businesses generate a higher profit margin than retail, so as Amazon continues to invest in these areas, it should lead to more profitable growth over the long term.

One area that continues to look promising is cloud services. Despite the increasing competition from Alphabet's Google Cloud and Microsoft Azure, Amazon is holding its share of spending of the cloud market steady in the 32% to 34% range, according to Synergy Research Group. Amazon just announced a $4 billion investment in Anthropic, an artificial intelligence (AI) research company, which will accelerate Amazon's push into generative AI services for its cloud customers. 

Apple: One of the most profitable brands around

At first glance, some investors might think Amazon is a better business. While Amazon generates more consistent revenue growth every year, Apple depends on millions of people choosing to buy an iPhone, which generates nearly half of the company's revenue. The dependency on iPhone sales has exposed Apple to less consistency on the top line, especially as the global smartphone market matures.

However, there's a good reason Warren Buffett has plowed billions into Apple stock. Apple is less consistent than Amazon in generating sales growth, but it says a lot about Apple's brand power that even with its dependency on the iPhone, it is a more profitable business than Amazon. This is not only due to earning a healthy margin on pricey hardware devices, but it also reflects Apple's lucrative business of selling subscriptions and apps to its growing installed base of devices. 

Through the first three quarters of the fiscal year ending in September, Apple's product sales fell nearly 6% year over year. This was due to lower sales across all its products, including Mac and iPad, in addition to wearables, home, and accessories. The only sales category that grew was services (e.g., subscriptions and app sales).

While a dip in product sales is nothing new at Apple, it does point to the primary weakness with Apple's business: lengthening upgrade cycles. Many iPhone users may only upgrade about once every five years, which isn't as ideal as having a large pool of customers make repeat purchases on a regular basis, such as at Amazon. But Apple is making up for this with its growing services business.

AAPL Revenue (TTM) Chart

AAPL Revenue (TTM) data by YCharts

The new iPhone 15 is reportedly seeing strong preorders that are running 10% to 12% higher than iPhone 14, so Apple might have another banner year for fiscal 2024. As Apple's revenue history shows, slow growth years are usually followed by a growth spurt, as customers might find features on the new models appealing enough to upgrade. 

To better understand Apple's future direction as a business, a more important metric to watch is the growth of the installed base of devices, which reached an all-time high of 2 billion at the start of 2022 and has doubled over the last seven years. This bodes well for continued growth in service sales, which makes up 21% of the business. The growth from higher-margin services should continue to drive earnings growth and shareholder returns. 

AAPL Chart

AAPL data by YCharts

Amazon and Apple benefit from high customer loyalty, but Apple sets itself apart by being able to invest massive sums in technology, new products, and services while converting its annual sales into consistent free cash flow. On a trailing-12-month basis, Apple generated $101 billion in free cash flow compared to Amazon's $3.2 billion. Those enormous cash resources allow Apple to pay a growing dividend to shareholders while also making investments in important technologies like AI that could lead to new services over time that fuel profitable growth.

Apple has the look of a better-performing stock

Apple is a more profitable business and trades at a cheaper valuation. At current share prices, Apple trades at a forward price-to-earnings (P/E) ratio of 28 compared to Amazon's forward P/E of 57. 

Based on free cash flow (FCF), Apple is also the cheaper stock, trading at a P/FCF multiple of 26. Even using Amazon's previous peak trailing-12-month free cash flow of $27 billion, the e-commerce leader trades at an expensive P/FCF multiple of 50. 

Apple's consistency on the bottom line has contributed to better returns to investors. Over the last five years, shares tripled in value, beating the small 33% gain from shares of Amazon. 

These are both outstanding companies, but I would allocate money to Apple stock, since it offers investors more value at current share prices.