Apple (AAPL -1.20%) and Microsoft (MSFT -1.07%) have been rivals and partners at different points throughout history dating back to the 1970s when both companies were founded. But today, their businesses are probably more different than ever before.

Apple is still focused on developing the computers and devices consumers have always loved, with the iPhone now leading its product portfolio. While Microsoft still develops software like its Windows operating system, its business is now driven by cloud computing services for businesses. 

Apple became the first company ever to amass a $1 trillion market capitalization in 2018, and it was worth as much as $3 trillion just three months ago. It has consistently been the world's largest company over the last few years, though Microsoft has briefly taken that title on a few occasions. 

Today, the valuations of these two companies are separated by just $180 billion, and I think there's a case for Microsoft surging ahead of Apple in the near future -- permanently!

A chart showing the market capitalizations of Apple and Microsoft.

Data source: YCharts.

Apple stock is trading 14% below its all-time high

Apple stock has fallen 14% since recording an all-time high at the end of July. A broader market sell-off is weighing on the stock, but the company is also suffering from internal issues. Its revenue has declined for the last three consecutive quarters as consumers pull back on spending amid elevated inflation and rising interest rates.

Apple just released the new iPhone 15 lineup of smartphone devices. The Pro models come with some of the company's best innovations yet, including one of the world's most powerful chips capable of rapidly processing artificial intelligence (AI) workloads on-device. Early indications suggest the new model will lift Apple's sales in the current quarter, but the smartphone market has matured, meaning the industry is driven mostly by upgrade cycles as opposed to new customers coming in. 

That will likely create a long-term headwind for the company, especially as new versions of the iPhone are so powerful that consumers no longer feel the need to upgrade every one or two years. 

Investors often point to Apple's services segment as a growth driver. It features popular subscription-based products like Apple Music, Apple News, and Apple TV in addition to innovations like Apple Pay. But the services business only accounts for 25% of Apple's total revenue, so it isn't big enough to offset a long-term stagnation in the hardware business (should that occur).

Microsoft stock, on the other hand, is down by just 8% from its all-time high. The company is positioning itself as a key distributor of exciting new technologies like artificial intelligence through its Azure cloud platform, which is delivering accelerated growth right now

Investors are pricing Microsoft stock at a premium to Apple

The price-to-earnings (P/E) ratio is an important metric to consider when valuing a stock. It's calculated by taking a company's share price and dividing it by its earnings per share (profit). 

Microsoft has generated $10.33 in earnings per share over the last four quarters (12 months), so based on its current stock price of $329.81, its P/E ratio is 31.9. Apple has generated $5.95 in earnings per share over the last four quarters, so based on its current stock price of $168.02, its P/E ratio is 28.2.

As you can see, Microsoft is trading at a premium to Apple of 13%. The decline in Apple's stock price has caused its P/E ratio to shrink. This is a phenomenon called "multiple contraction" where investors decide a company is worth a lesser premium than before. Since Apple's sales have failed to grow over the last few quarters, as I touched on earlier, investors have adjusted the company's valuation. 

On the flipside, Microsoft has delivered continuous growth, which has earned it a higher P/E ratio. Plus, thanks to its focus on the cloud and AI, investors feel confident about the company's ability to deliver more growth in the future, which means they're willing to pay a higher price for its stock. 

Microsoft could soon become the world's most valuable company

AI is going to be critical for Microsoft going forward, because it already has the infrastructure in place to deliver the technology to businesses all over the world thanks to its Azure cloud platform. In fact, Microsoft is one of the only companies in the world -- alongside Nvidia -- successfully monetizing AI at the moment.

Earlier this year, Microsoft invested $10 billion in ChatGPT developer OpenAI. It has integrated OpenAI's technology into most of its product portfolio, including Windows, the 365 document suite, the Edge internet browser, the Bing search engine, and, of course, Azure. 

In the recent fiscal 2024 first quarter (ended Sept. 30), Microsoft's Azure OpenAI Service segment had 18,000 business customers, an increase of 63% from just three months earlier. Azure overall generated 29% year-over-year revenue growth, and Microsoft said three percentage points of that was attributable specifically to AI. That's triple the contribution AI made in the prior quarter.

Microsoft is set to scale its AI monetization in several other ways, too. In Q1, it said 40% of the Fortune 100 companies and tens of thousands of their employees were using its new Copilot tool, which injects AI into popular software applications like Word, Excel, PowerPoint, and Outlook. Copilot was still in beta mode during the quarter, but it's now undergoing a broad release which could be incredibly lucrative for Microsoft considering it's priced at $30 per user, per month. 

If Microsoft continues to focus on AI, its long-term financial opportunities will be substantial. Goldman Sachs predicts the technology will add $7 trillion to the global economy by 2030. Cathie Wood's Ark Investment Management places that figure at $200 trillion!

In any case, I expect the valuation gap between Microsoft and Apple to continue to narrow thanks mostly to AI until Microsoft eventually becomes the largest company in the world and holds that title for the long run.