All eyes have been on Microsoft (MSFT 0.41%) and Nvidia (NVDA 0.87%) this year, thanks to a boom in artificial intelligence (AI). Microsoft has soared to the top of the software part of the market, while Nvidia dominates in hardware. These companies have solid long-term outlooks, making their stocks attractive options right now.

In addition to AI, Microsoft is a leader in productivity software and is inches away from completing a deal that will make it the world's third-largest video game company. Meanwhile, Nvidia's chips have become integral to countless industries, from AI to cloud computing, gaming, consumer products, and more. 

Microsoft and Nvidia have carved out lucrative positions in tech and likely have a lot to offer investors in the coming years. So, let's look at which is the better buy. 

Microsoft: A diversified business model

Microsoft has been featured in countless headlines this year for its AI efforts, with its 49% stake in ChatGPT developer OpenAI making Wall Street particularly bullish. However, AI isn't the only reason to invest in this tech giant. The company boasts a thoroughly diverse business as the home of brands such as Windows, Office, Xbox, and Azure. The success of its products has boosted annual revenue by 68% over the last five years, with operating income up 106%.

Millions of consumers worldwide have come to depend on Microsoft's productivity software, an increasingly lucrative area with the rise of subscription-based platforms. In fiscal 2023 (ended in June), Microsoft 365 subscribers rose 12% year over year to 67 million. Meanwhile, operating income for its productivity segment hit $4.5 billion, increasing 15%. The company is steadily adding AI features across its lineup, which could offer another boost to earnings as more consumers seek such services to increase efficiency.

Moreover, Microsoft has become one of the biggest names in video games with its Xbox brand. The company is close to completing its $69 billion deal to purchase developer Activision Blizzard. This month, U.K. regulators, the last remaining agency needed to sign off on the purchase, said Microsoft had taken necessary actions to "substantially" address antitrust concerns. Acquiring Activision Blizzard will give Microsoft access to a valuable library of content that will be a powerful tool in attracting subscribers to its Xbox Game Pass service.

Microsoft shares have soared 174% over the last five years. It has a long history of reliable growth and is a compelling investment with positions in multiple high-growth industries.

Nvidia: Snapping up market share in a $137 billion industry 

Nvidia's stock has skyrocketed 187% year to date as its chips have become crucial to AI, a market worth $137 billion and projected to expand at a compound annual growth rate of 37% through 2030.

The company holds a majority market share in graphics processing units (GPUs), the chips necessary for developing AI models. As a result, Nvidia is now the go-to for AI-minded companies seeking powerful hardware. Meanwhile, chipmakers like Advanced Micro Devices and Intel have been left playing catch-up as they work to produce chips that can match Nvidia's offerings.

Nvidia's command of the AI chip market sent revenue soaring 101% year over year in the second quarter of 2024 (ended July 2023), fueled by a 171% rise in data center revenue. Moreover, the company expects to deliver larger gains in its current quarter as supply strains resolve quicker than expected.

The company is massively profiting from increased interest in AI. However, investor excitement seems to be dissipating. Its stock has tumbled 9% since reporting Q2 2024 earnings on Aug. 23. Despite glowing quarterly results, Nvidia's bull run this year likely suggests much of its short-term growth is already priced into its shares.

Is Microsoft or Nvidia the better buy?

Microsoft and Nvidia are winning in tech this year and have massive growth potential over the long term. However, Microsoft is the better buy right now with a better-valued stock and reliability that comes from leading positions in multiple areas of tech.

NVDA PE Ratio Chart

Data by YCharts.

The chart above shows Microsoft's price-to-earnings ratio (P/E) and price-to-free cash flow are significantly lower than Nvidia's. These are helpful metrics in determining a stock's value as they compare a company's financial health with its share price. For both metrics, the lower the figure, the better, and Microsoft comes out on top on both fronts.

For a lower price, investors can arguably get an equal investment in the AI market and profit from Microsoft's growth in several other subsectors of the tech industry. The company is the cheaper and more reliable option this month.