Silicon Valley has been the unofficial mascot of tech behemoths for years. But perhaps ironically, two of the largest technology leaders for decades don't directly hail from the Bay Area.

Cupertino, California-based Apple is one of the most-recognized consumer electronics businesses of all time. From the iPod to the iPhone, Apple flourished under visionary leader Steve Jobs. Since 2011, the company has been led by Tim Cook. Under Cook's reign, Apple's market capitalization has increased nearly tenfold. At this writing, Apple's market cap was about $2.9 trillion.

But the company's longtime rival, Seattle-based Microsoft (MSFT 1.82%), has quietly caught up to Apple's influence. For now, Microsoft is the most valuable company in the world -- worth over $3 trillion.

I suspect Apple and Microsoft will go back and forth between the world's largest enterprise for a bit. However, one of these "Magnificent Seven" stocks is emerging as the clear winner. Let's dig into how Microsoft reinvented itself, and more importantly, why the long-term picture looks better than ever.

The rise of Satya Nadella and a new Microsoft

Apple has a long list of groundbreaking innovative products. The company revolutionized how music is consumed with the introduction of the iPod. Furthermore, both the MacBook and iPad disrupted the personal-computing (PC) market, giving creatives an entirely new way to produce content. And perhaps most importantly, the advent of the iPhone reinvented how people communicate on a daily basis.

Therefore, it's not surprising that the combination of such a deep and prolific portfolio of products helped Apple become the world's first trillion-dollar company.

On the other side of the equation is Microsoft. While the company is a pioneer for modern-day computing applications, Microsoft spent many years in Apple's shadow. The company resorted to a host of acquisitions to drive growth and product innovation.

But in 2014, Microsoft named Satya Nadella as its new CEO. Eerily similar to Cook, Nadella has helped propel Microsoft's value by approximately tenfold over the last decade.

How did Nadella inspire such robust growth in just 10 years? A close look at the executive's background will shed some light on how he reinvented the Windows developer.

An image of stocks trending upward on a chart with a bull.

Image source: Getty Images

A first look at artificial intelligence (AI) in the business

Before taking over as CEO, Nadella led Microsoft's cloud division. The company recently reported earnings for the second quarter of fiscal 2024, ended Dec. 31. While total revenue increased 18% year over year to $62 billion, the cloud division was the big winner.

One reason why the cloud is becoming increasingly important for Microsoft is its infusion of artificial intelligence (AI) features into the platform. Microsoft is a large investor in OpenAI, the developer of ChatGPT. Over the last year, Microsoft swiftly integrated ChatGPT across its ecosystem -- a move that is already paying off in spades.

During the earnings call, Nadella proclaimed, "We've moved from talking about AI to applying AI at scale."

Given that Microsoft Cloud increased 24% year over year to $33.7 billion of revenue in the quarter, I'd say Nadella's commentary is holding true. But although artificial intelligence (AI) carries some exciting prospects for Microsoft, investors should take a thorough look at the company's valuation before pouring into the stock.

Should you invest in Microsoft stock?

As of the time of this writing, Microsoft trades at a forward price-to-earnings (P/E) multiple of 36 -- well above its 10-year average of 30. By comparison, cloud specialists Amazon and Alphabet trade at forward P/E multiples of 47 and 21, respectively.

While Microsoft stock is right in the middle among its top competition, the stock isn't exactly cheap. The forward P/E of the S&P 500 is about 22, considerably lower than Microsoft and its cohorts.

I don't think that the impact of artificial intelligence (AI) is fully baked into Microsoft stock. But this analysis illustrates that investors are placing a premium on the biggest names in AI.

Despite its rich valuation, it is hard to pass up on Microsoft. The company is growing at an impressive rate, and its ambitions with AI are in very early stages. I think the company is well positioned for the long term, and the stock could very well be on its way to new highs. Now could be a good time to use dollar-cost averaging to initiate or add to a position in the stock.