Both Microsoft (MSFT 0.37%) and IBM (IBM 1.05%) have had to shift their strategies in recent years to keep delivering growth for shareholders. However, despite slowing PC sales and competition from Apple, Microsoft has had far greater success than IBM in keeping its business momentum going. Microsoft is known for its dominance with its Windows operating system and Office software, but over the last two years, it has emerged as one of the largest cloud providers in the world.

IBM is investing heavily in the cloud, too, but it's struggling to keep up with fast-growing tech rivals, including Microsoft. Of course, the decision to buy either of these stocks should be based on more than just who is growing faster in the cloud space. We'll compare both companies' financial positions, valuations, dividends, and most importantly, their competitive positions to determine which is the better buy today.

Check out the latest Microsoft and IBM earnings call transcripts.

A man's hands typing on a laptop keyboard with white clouds hovering above the computer

IMAGE SOURCE: GETTY IMAGES.

Financial fortitude

A review of a company's financial health tells investors more than merely which company can hold up better during periods of softening in the economy. A company with strong financial fortitude has more opportunities to deliver returns to shareholders by developing new products, making profit-building acquisitions, or paying a rising dividend over time.

With that in mind, here's a review of how both companies measure up on key financial metrics: 

Metric Microsoft  IBM
Cash $127.66 billion $12 billion
Debt $73.17 billion $45.18 billion
Revenue (TTM) $118.46 billion $79.59 billion
Free cash flow (TTM) $31.9 billion $11.53 billion
Free cash flow as a percentage of revenue 26.9% 14.5%

Data source: YCharts. TTM = Trailing 12 months.

Microsoft is clearly the winner on this crucial test. The software giant has about $54.5 billion of net cash, after subtracting debt, whereas IBM has more debt than cash. 

Winner: Microsoft.

Valuation and dividends

A better-buy comparison is never complete without considering valuation. Comparing these two stocks on a range of widely used metrics will help guard against overpaying for a company's earnings. Here's how shares of Microsoft and IBM stack up: 

Metric Microsoft IBM
Trailing P/E 25.1 14.51
Forward P/E 21.7 9.74
PEG ratio 1.72 10.22
Price-to-free cash flow 26.4 10.97
Dividend yield 1.72% 4.6%
Dividend payout as a percentage of free cash flow 41.44% 49.14%

Data sources: YCharts and Yahoo! Finance.

At first glance, IBM seems like the better value. However, keep in mind, analysts expect Big Blue to grow earnings by 1% per year over the next five years, so the company's low price-to-earnings multiple should come with a warning label. On the other hand, analysts expect Microsoft to grow earnings by 14% per year going forward -- that's why Microsoft has a lower PEG (price-to-earnings-growth) ratio.

Nonetheless, any improvement in IBM's earnings growth would likely cause investors to adjust their expectations, which would send Big Blue's stock price higher. So, I'll give IBM the benefit of the doubt.

Looking at dividends, IBM seems like the winner. It pays a juicy yield, which income investors should find appealing. But again, caution is warranted.

I recently made the argument that Microsoft is a better dividend growth stock than IBM, and I'm sticking to it. IBM's yield is tempting, but Microsoft has actually grown its dividend at a faster rate than IBM in recent years. Meanwhile, IBM hasn't grown its free cash flow, and unless that turns around, future dividend increases will be hard to come by.

I give IBM the edge on valuation, but I'm sticking with my call that Microsoft is a better dividend stock. So, this one is a draw.

Winner: Tie.

Competitive moat

Microsoft continues to deliver robust results for shareholders stemming from its competitive advantages, including network effects, switching costs, and brand. In the fiscal second quarter, revenue increased 12% year over year, driven by 48% growth in the commercial cloud business. Within the cloud business, Azure grew 76% for the second consecutive quarter as companies continue partnering with Microsoft for their cloud-computing needs, including Kroger, Mastercard, and Walgreens Boots Alliance.

Additionally, the software giant's shift to a subscription-based model for Office continues to produce solid results. Microsoft now has 33.3 million subscribers to Office 365. Revenue from Productivity and Business Processes (including Office 365, Dynamics 365, and LinkedIn) grew 13% year over year in the last quarter.

Microsoft has one of the top brands in the world, which is a result of the familiarity millions of people and organizations have with Windows and Office software. The company is starting to leverage that technological know-how and brand recognition in other exciting areas, including Internet of Things, artificial intelligence, and Mixed Reality, in addition to cloud-computing. 

On the other side, IBM has been serving corporate clients for years. Big Blue has extensive expertise in consulting companies across many industries to help them compete more effectively. 

IBM's main problem is finding growth. While IBM is not going anywhere, it's also not likely to grow much in the next few years. About half of IBM's business is stuck in slow-growing markets like legacy IT services, hardware, and software services. 

However, as you can see with Microsoft's recent growth, cloud spending is where all the action is. IT spending is undergoing a massive to shift to the cloud, which doesn't play to IBM's strengths. While IBM saw its cloud business grow 12% last year, that's peanuts compared to Microsoft's growth in the cloud. IBM's cloud market share is about 2%, while Microsoft saw its share jump from 8.7% in 2016 to 13.3% in 2017. 

Amazon.com and Microsoft are absorbing most of the cloud spending right now. IBM's recent acquisition of Red Hat will help, but overall, Microsoft is in a much stronger competitive position.  

Winner: Microsoft.

Microsoft is the better buy

IBM could be a good contrarian bet, especially if the company begins to show signs of growth again. But for now, I'd rather go with consistency. Microsoft has the financial fortitude, growth, and competitive advantages that make the king of software a no-brainer pick.