With their cloud-computing businesses helping to turbocharge growth, Amazon.com (NASDAQ:AMZN) and Microsoft (NASDAQ:MSFT) have become two of the most valuable businesses in the world. Along the way, they've created life-changing wealth for long-term investors.

But which of their stocks is the better buy today? Let's find out.

Competitive advantage

One area where Microsoft and Amazon compete directly is the public cloud market, which is expected to exceed $300 billion by 2021, according to Gartner. Amazon is the industry leader in cloud infrastructure services, with a greater than 50% share, compared to less than 15% for Microsoft, although market share numbers vary by source. However, Microsoft is growing much faster; its Azure cloud platform revenue surged 76% year over year in the third quarter. Amazon Web Services' revenue, meanwhile, rose 46%. 

As the largest player in the industry, Amazon enjoys scale advantages over its rivals. This allows it to better leverage its cost base. Amazon then passes on these savings to customers; AWS has already reduced prices four times in 2018 and 67 times since its inception in 2006. The price reductions, in turn, help fuel further growth, creating a virtuous cycle for the cloud leader.

Computer circuits connecting to a digital cloud

Amazon and Microsoft are battling for cloud supremacy. Image source: Getty Images.

Although it's the No. 2 player in the industry, Microsoft has a powerful advantage: It's not Amazon. After struggling for years to combat the online juggernaut's stunning growth, many retailers are choosing to give their cloud business to Amazon's rivals. Microsoft is filling this role nicely, and it has scored some major wins in the process. 

Still, Amazon's significantly higher market share is a testament to its overall competitive strength. This will be an interesting battle to watch going forward, but for now, Amazon has the edge.

Advantage: Amazon

Financial fortitude

Let's review some key financial metrics for these two cloud giants.

Metric

Amazon

Microsoft

Revenue

$220.96 billion 

$114.91 billion 

Operating income

$10.76 billion

$37.31 billion

Operating cash flow

$26.67 billion

$45.10 billion

Free cash flow

$13.36 billion

$32.00 billion

Cash

$29.76 billion 

$135.77 billion 

Debt

$47.22 billion

$87.93 billion

Data sources: Morningstar, Yahoo! Finance.

Amazon generates nearly twice as much revenue as Microsoft. Yet Microsoft is vastly more profitable, with an operating margin of 32.5%, compared to less than 5% for Amazon. In turn, Microsoft's operating income, operating cash flow, and free cash flow are all significantly greater than those numbers at Amazon.

Microsoft also possesses the stronger balance sheet, with nearly $48 billion in net cash. Amazon, meanwhile, has more than $17 billion in net debt.

For these reasons, Microsoft has the edge in terms of financial strength.

Advantage: Microsoft

Growth

Despite Microsoft's superior cloud growth, Amazon is expanding its overall earnings base at a far more rapid clip.

Wall Street expects Amazon to increase its earnings per share at more than 44% annually over the next half-decade, fueled in part by the continued growth of AWS and a booming advertising business. During this same period, Microsoft's profits are projected to rise by less than 14% annually,  with slower growth in its Windows franchise expected to somewhat offset the company's torrid cloud gains.

Thus, Amazon clearly has the edge in this comparison.

Advantage: Amazon

Valuation

Finally, let's compare some key value metrics, including price-to-free cash flow (P/FCF) and price-to-earnings (P/E) ratios.

Metric

Amazon

Microsoft

P/FCF

60.69

26.26

Trailing P/E

92.92

45.08

Forward P/E

62.13

21.76

Data sources: Morningstar, Yahoo! Finance.

Microsoft is significantly cheaper on both a price-to-free cash flow and price-to-earnings basis. Investors who buy Amazon's shares today would need to pay more than twice as much per dollar of earnings and free cash flow than they would for Microsoft. They'd also be paying nearly three times as much per dollar of earnings that these businesses are expected to produce in the next year. As such, Microsoft's shares are currently the better bargain.

Advantage: Microsoft

The better buy is...

Ultimately, you'll need to decide which of these factors is most important to you. Value-focused investors may gravitate toward Microsoft's superior financials and more attractively priced shares. Growth investors will no doubt appreciate Amazon's strong competitive positioning and incredible earnings growth prospects.

In the end, the best move may be to simply buy both of these world-class businesses, thereby doubling your chances at profiting from the expansion of the massive global cloud-computing market in the years ahead.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Teresa Kersten, an employee of LinkedIn, a Microsoft subsidiary, is a member of The Motley Fool's board of directors. Joe Tenebruso has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Amazon. The Motley Fool owns shares of Microsoft. The Motley Fool recommends Gartner. The Motley Fool has a disclosure policy.