Microsoft (MSFT -1.64%) and Alphabet (GOOG -4.08%) (GOOGL -4.02%) are no strangers to competition.

These tech giants have duked it out in a wide range of categories, including cloud computing, internet browsers, office productivity software, and more, but the competition is now heating up as investors turn their attention to artificial intelligence (AI). Both companies appear to be early leaders in this emerging technology. Alphabet has long been investing in AI, acquiring the AI research lab DeepMind nearly a decade ago, while Microsoft benefits from its partnership with OpenAI, the creator of ChatGPT.

Both stocks have surged this year, in part due to excitement over AI, but which is the better buy today? Two Motley Fool contributors take sides to try and answer the question.

Microsoft: Playing offense in the new tech frontier

Jeremy Bowman (Microsoft): OpenAI shook up the world with the launch of ChatGPT, and Microsoft is a major reason why. The tech giant has now invested $13 billion in the AI start-up, and the two have a close partnership.

ChatGPT powers the new Bing search engine, allowing users to chat with an interface, like they do on ChatGPT, and Microsoft has incorporated OpenAI's technology into a wide array of products, including its Office suite, GitHub code repository, its new Edge internet browser, and Azure, the cloud infrastructure business that now anchors Microsoft's largest operating segment.

Azure OpenAI continues to look like a big winner for the company. Just this week, Azure expanded its AI partnership with Teladoc Health and MongoDB, and it just launched a new $30/month AI subscription plan, known as Copilot, for Microsoft 365, its suite of Office products including Word, Excel, Powerpoint, and others. Additionally, Microsoft announced new updates to Bing, including visual search, and continues to pour resources into new AI products.

While dethroning Google Search may be a long shot, Microsoft is making the battle more interesting than it has been in years, and Alphabet's business model is also threatened by chat-based search in a way that Microsoft's is not since Alphabet makes almost all of its money from advertising and more than half of its profits come from search.

Microsoft, on the other hand, is much more diversified, with profitable businesses ranging from Azure to Office software to Windows to gaming systems like Xbox, advertising through LinkedIn, Edge, Bing, and more. That helps better insulate the business against disruptive changes like AI. 

Microsoft stock may be expensive right now, but it's making all the right moves in AI, and it owns a set of complementary businesses that is unmatched in the tech sector and gives it a competitive advantage.

Alphabet: The tech titan with a wallet-friendly price tag

Anders Bylund (Alphabet): I have nothing but respect for Microsoft under the deft leadership of CEO Satya Nadella. However, Wall Street loves Redmond's stock even more, and I'm not comfortable buying into Microsoft at these red-hot prices.

On the other hand, Alphabet trades at very reasonable share prices even though its long-term prospects are just as bright as Microsoft's.

It feels strange to say this about Google's massive parent company, but Alphabet feels like the worst-kept secret in today's tech sector.

Did you know that Alphabet's revenue dwarfed Microsoft's over the last four quarters, $285 billion to $208 billion? Alphabet is also more profitable, generating $55.9 billion of free cash flow. Microsoft's cash flow stopped at $43.0 billion.

I understand that Microsoft is a powerhouse in cloud-based AI services, with a big hand in the success of OpenAI's ChatGPT. But Alphabet and Google have explored the AI space for decades, and I can't even imagine the game-changing machine learning systems this company runs behind the scenes. Now that AI concepts are entering the mainstream of consumer culture and business practices, I expect the company to start monetizing AI tools we've never seen before.

Yet, market makers seem to appreciate Microsoft's AI-based prospects much more. The software veteran's stock is skyrocketing in 2023, leaving rivals like Alphabet far behind.

As a result, Microsoft trades at a nosebleed-inducing 12 times sales and 67 times free cash flow with a market cap north of $2.55 trillion. The equally impressive (and in some ways superior) peer we know as Alphabet offers a more comfortable buy-in point at 5.5 times sales and 25 times free cash flows.

Master investor Warren Buffett famously looks for "a wonderful company at a fair price." Here, we're looking at two wonderful companies but only one fair price. That's why I'm a buyer of Alphabet stock in July 2023. I'm waiting for Microsoft's overheated stock to cool down a bit before I touch it.