Microsoft (NASDAQ:MSFT) and Oracle (NYSE:ORCL) have long dominated the tech landscape. Yet recently, their fortunes have diverged. Microsoft's business is firing on all cylinders, and its shares are up more than 35% in the past year. Oracle, on the other hand, has struggled with tepid growth and a wilting stock price.

But which of these stocks is the better buy today? Is the strong performance of Microsoft's shares a sign that more gains lie ahead? Or have investors become too bearish on Oracle, thereby making its stock the bigger bargain? Read on to find out.

Competitive position

One major area where Microsoft and Oracle compete directly is in the cloud computing arena -- a massive market that's projected to grow to more than $300 billion by 2021, according to Gartner.

Oracle has been talking a big game about its cloud ambitions for years. Back in 2016, executive chairman Larry Ellison promised that Oracle would soon displace Amazon (NASDAQ:AMZN) as the industry leader. "Amazon's lead is over," Ellison said. "Amazon's going to have serious competition going forward."

Yet Ellison's words have proven hollow. Oracle has failed to make much progress in its cloud initiatives, particularly as it relates to taking share from Amazon and other industry leaders. Oracle's public cloud business is not even among the top five public cloud providers in terms of market share, according to Gartner. Moreover, Oracle's cloud revenue has been growing in the 20% range in recent quarters, compared to more than 40% for Amazon. Perhaps most troubling is that Oracle recently changed the way it reports its cloud revenue, leading some investors to speculate that the company's cloud growth may be slowing.

Microsoft, conversely, is rapidly gaining share. Microsoft is currently the No. 2 cloud provider, and its Azure cloud service revenue surged 89% in the most recent quarter.

Microsoft has become a trusted ally for retailers that don't want to give their cloud business to rival retailer Amazon. Azure is also strengthened by Microsoft's extensive artificial intelligence capabilities. CEO Satya Nadella has placed Azure at the core of Microsoft's business, and the company is investing aggressively to further its growth.

All told, many signs point toward Microsoft's continued success, while Oracle has so far failed to prove that it can compete effectively in this vital market. I'd argue that Microsoft is in a far stronger competitive position.

Advantage: Microsoft.

Financial fortitude

Let's now take a look at some key financial metrics to see how these tech giants compare:

Metric Microsoft Oracle Revenue $110.36 billion $39.92 billion Operating income $35.06 billion $14.32 billion Operating cash flow $43.88 billion $15.54 billion Free cash flow $32.25 billion $13.90 billion Cash and investments $133.67 billion $60.09 billion Debt $87.51 billion $58.30 billion

Both Microsoft and Oracle are exceptionally profitable businesses, with operating margins of 31.77% and 35.86%, respectively. Moreover, Oracle is certainly a financially sound enterprise, with $60 billion in cash reserves and nearly $14 billion in annual free cash flow. Microsoft, however, is simply in a different league; its more than $133 billion in cash and investments and $32 billion in free cash flow dwarf its smaller rival's. Thus, Microsoft has a clear edge in terms of financial strength.

Advantage: Microsoft.

Growth

Microsoft's sales and profits have also grown significantly faster than Oracle's in recent years. In fact, while Microsoft's operating income rose by more than 25% over the past half-decade, Oracle's profits actually declined during this time:

Wall Street expects this trend to continue. Microsoft is projected to grow its earnings per share by more than 13% annually over the next five years, fueled by the growth of Azure and its other cloud initiatives. Meanwhile, analysts forecast that Oracle will increase its EPS by about 8% per year, driven largely by share repurchases. So here too, Microsoft has the edge.

Advantage: Microsoft.

Valuation

Finally, let's check out some key valuation metrics for these tech titans, including their price-to-free-cash-flow (P/FCF), price-to-earnings (P/E), and price-to-earnings-to-growth (PEG) ratios:

Metric Microsoft Oracle P/FCF 25.63 13.05 Forward P/E 21.75 13.16 PEG 1.95 1.74

Oracle's shares are considerably less expensive than Microsoft's in terms of price to free cash flow and price to earnings. This is to be expected, considering Oracle's lower projected growth rates. But even if we account for Microsoft's higher expected earnings growth -- as we do with the PEG ratio -- Oracle's stock is still more attractively priced. Thus, Oracle gets the edge here.

Advantage: Oracle.

The better buy is...

Oracle's stock may be cheaper. But Microsoft's stronger competitive position, superior financial strength, and greater growth prospects make it the better long-term investment.