With market caps of $650 billion and $570 billion, respectively, Microsoft (MSFT -0.68%) and Amazon.com (AMZN -0.89%) possess a level of size and scale that only a handful of companies in the world can claim. As these companies have risen to power, they've earned a fortune for their investors along the way.

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

Two elephants facing each other

Amazon and Microsoft are two of the biggest beasts in the public markets. We put them head-to-head to see which is the best buy for your portfolio. Image source: Getty Images.

Moat

For more than two decades, Microsoft's Windows operating system dominated the personal computer market. In recent years, however, Apple and Google have been chipping away at its lead in PCs with their popular Macs and Chromebooks. And as the world has gone mobile, iOS and Android have become the most powerful operating systems, making Microsoft's PC strength less significant.

Conversely, Amazon's competitive moat is growing stronger by the day. Its dominant consumer mindshare and massive scale advantages are helping Amazon fortify its position as the king of online retail. Moreover, they make it extremely unlikely that rivals will be able to overtake the e-commerce juggernaut.

One area where Amazon and Microsoft compete directly is in the cloud-computing infrastructure market. Here again, Amazon is the market leader, with a 35% share compared to less than 15% for Microsoft, according to Synergy Research. To be fair, Microsoft's cloud revenue has been growing at a faster rate than Amazon Web Services (AWS), albeit from a far smaller base.

Microsoft's primary advantage in this area may be simply that it's not Amazon. Major customers, such as Wal-Mart, have been urging their customers to switch from AWS to Microsoft's Azure cloud service, in hopes of curbing Amazon's staggering growth. Yet while this is helping to prop up Microsoft's cloud business, it's not enough to give it the edge in terms of competitive advantage over Amazon.

With its increasing dominance in multiple high-growth markets, Amazon has the wider moat.

Advantage: Amazon.

Financial fortitude 

Amazon and Microsoft are both elite businesses, but let's take a look at some key metrics to see how they stack up in regards to financial strength.

Metric

Amazon

Microsoft

Revenue

$161.2 billion

$92.6 billion

EBITDA

$14.0 billion

$36.2 billion

Net income

$1.9 billion

$22.1 billion

Operating cash flow

$16.2 billion

$40.4 billion

Free cash flow

$7.2 billion

$32.3 billion

Cash

$24.3 billion

$138.5 billion

Debt

$24.7 billion

$85.5 billion

DATA SOURCES: MORNINGSTAR.

Although Amazon is certainly no slouch, Microsoft's fortress-like balance sheet and massive free cash flow production make it one of only two U.S. non-financial companies to earn a AAA credit rating from the major rating agencies. As such, Microsoft comes out ahead in terms of financial strength.

Advantage: Microsoft.

Growth

When it comes to growth, this better-buy battle is particularly one-sided. Amazon's revenue and cash flow growth has dwarfed that of Microsoft over the past half-decade.

AMZN Revenue (TTM) Chart

AMZN Revenue (TTM) data by YCharts.

This trend should continue for the foreseeable future, with analysts forecasting that Amazon will grow its earnings per share at more than 50% annually over the next five years compared to only about 10% for Microsoft. With a projected earnings per share (EPS) growth rate that's five times that of its rival, Amazon is simply in a different league in terms of growth.

Advantage: Amazon.

Valuation 

No better-buy discussion should take place without a look at valuation. Let's check out some key value metrics for Amazon and Microsoft, including price-to-earnings (P/E) and price-to-free-cash-flow (P/FCF) ratios.

Metric

Amazon

Microsoft

Trailing P/E

299.28

31.06

Forward P/E

147.46

22.27

P/FCF

78.52

20.11

DATA SOURCES: YAHOO! FINANCE, MORNINGSTAR.

On all three metrics, Microsoft's shares are far less expensive than Amazon's. Even if we factor in Amazon's significantly higher expected growth rates, Microsoft's stock is still more attractively priced based on its price-to-earnings-to-growth, or PEG, ratio of 2.37 compared to 4.65 for Amazon. Thus, Microsoft is the better bargain.

Advantage: Microsoft.

Additional factors

With this better-buy showdown all tied up after four rounds, let's look at some additional aspects of these mega caps' businesses to help you decide what's best for your portfolio.

Income-seeking investors will likely appreciate Microsoft's steadily rising dividend, which currently yields 2%. The tech titan also repurchased $10 billion  of its shares during the past year, which further helps to support it stock price. Amazon, in contrast, does not pay a dividend and only buys back its stock sparingly.

Alternatively, growth-focused investors may appreciate Amazon's relentless desire to enter new markets. The e-commerce juggernaut is expanding aggressively in areas as diverse as groceries, esports, and smart home products, as well as many other areas. In fact, billionaire media titan John Malone recently said that Amazon is a "Death Star" that could "disrupt every industry on the planet." While its reach might not extend quite that far, the optionality in Amazon's business model is perhaps unmatched by any other public company.

Advantage: You decide.

Ultimately, you'll have to decide which of these factors is more important to you. If you're an income-focused investor who appreciates a reliable cash-dividend stream, then Microsoft is the way to go. If you're more of an aggressive growth-type investor, then Amazon is the better choice. Either way, you'll be buying a top-tier business that should continue to generate strong returns in the coming years.