Microsoft (MSFT 0.90%) and Alphabet (GOOG 0.02%) (GOOGL 0.01%) were two of the best-performing tech stocks of 2021. Over the past 12 months, Microsoft's stock price rallied 45% as Alphabet's stock advanced 59%. Both stocks easily beat the S&P 500's 24% gain.

But will these two tech titans beat the market again this year? Let's take a fresh look at both companies and see if either one is a better investment.

A visualization of a cloud  on top of a circuit board.

Image source: Getty Images.

The differences between Microsoft and Alphabet

Microsoft splits its sprawling business into three main segments: Productivity and Business Processes (Office, Dynamics, and LinkedIn), Intelligent Cloud (Azure and its other cloud services), and More Personal Computing (Windows, Xbox, Surface, Bing, and online advertising). Each business traditionally generates roughly a third of its total revenue.

Microsoft also regularly discloses the growth of its cloud business, which includes all the cloud-oriented businesses across all of its segments. Its cloud business generated nearly half of its total revenue in its latest quarter.

Alphabet is less diversified than Microsoft. It generated 82% of its revenue from Google's advertising business (including YouTube) last quarter. Google's non-advertising businesses, including its hardware and subscription services, generated 10% of its revenue, while Google Cloud accounted for 8%.

Alphabet's "other bets" -- which include its Waymo driverless cars, Calico and Verily life science divisions, and other experimental "moonshot" businesses -- bring in less than half a percent of its revenue.

Microsoft's cloud business is also much larger than Google's. Microsoft's cloud platform Azure controlled 21% of the cloud infrastructure market in the third quarter of 2021, according to Canalys, putting it in second place behind Amazon (AMZN 0.61%) Web Services' (AWS) 32% share. Google ranks a distant third with an 8% share.

Alphabet currently faces more regulatory headwinds than Microsoft. Specifically, Google's online search, advertising, and mobile OS businesses face a growing number of antitrust probes in Europe, the U.S., and other regions. Microsoft's recent bundling strategies have also attracted some regulatory scrutiny, but those investigations are minor compared to the recent actions against Google.

Which tech giant is growing faster?

Microsoft's revenue and adjusted earnings rose 18% and 38%, respectively, in fiscal 2021 (which ended last June).

The pandemic briefly throttled the growth of enterprise-facing businesses in the first half of the fiscal year, but it easily offset that deceleration with the growth of its cloud, gaming, and consumer-oriented businesses, which all benefited from remote work and stay-at-home trends.

The pandemic-related headwinds faded as the year progressed, and its cloud business continued to expand with 34% growth during the year. That expansion was largely led by Azure, Dynamics, and Office 365.

Analysts expect Microsoft's revenue and adjusted earnings to grow 17% and 15%, respectively, in fiscal 2022. The cloud business will likely remain its core growth engine, but the Xbox, Windows OEM, and Surface businesses should also perk up as they resolve their supply chain issues.

Alphabet's revenue and diluted earnings per share grew 13% and 19%, respectively, in fiscal 2020 (which aligns with the calendar year).

The pandemic's initial impact reduced Google's ad sales in the first half of the year, but the growth of Google Cloud -- which continued to gain new customers as it faced intense competition from AWS and Azure -- largely offset that slowdown. Google's ad business recovered in the second half of the year, and its cloud business continued to expand.

Analysts expect Alphabet's revenue to rise 39% and 85%, respectively, in 2021 as it faces easy year-over-year comparisons to the pandemic. In 2022, they expect its revenue and earnings to grow 17% and 4%, respectively, as those year-over-year comparisons normalize.

The valuations and challenges

Microsoft trades at 37 times forward earnings, while Alphabet has a much lower forward price-to-earnings ratio of 26.

That valuation gap reflects the bullish optimism for Microsoft's cloud growth and the bearish concerns regarding Alphabet's antitrust threats. Google's advertising business could also be affected by Apple's privacy changes on iOS and an inflation-driven reduction in ad sales.

But investors should recall that Alphabet has weathered plenty of regulatory challenges before, and its advertising business remained resilient last year even as inflation rose and Apple's iOS update struck down Meta Platforms, Snap, and other digital advertising platforms.

The winner: Alphabet

Both of these tech giants are solid long-term investments, but Alphabet's lower valuation makes it a better buy for 2022.

Microsoft's valuation has been inflated by its reputation as a safe-haven tech stock, but that high multiple could also limit its gains this year. Meanwhile, investors will likely rotate back toward Alphabet when they realize that its regulatory and platform challenges won't cause any lasting damage.