After a challenging year for the tech market, when the Nasdaq-100 Technology Sector index plunged 32% since January, many of the world's most valuable companies are trading at bargain prices.

Microsoft (MSFT 0.37%) and Alphabet (GOOG 0.74%) (GOOGL 0.55%) are titans of the tech world, yet have suffered double-digit declines in their shares this year. Heading into 2023, both companies are looking forward to promising opportunities for growth. You can't go wrong with an investment in either of these market-leading companies. However, one is ultimately the better buy. Let's assess. 

1. Microsoft

Microsoft's stock has slipped 27% year to date, as declines in consumer spending in the tech industry have spooked investors. However, the company is home to market-leading brands such as Windows, Office, Xbox, LinkedIn, and Azure, with plans to expand further in 2023. 

The cloud computing industry is booming, making Microsoft's Azure especially attractive with its 21% second-largest market share. According to Grand View Research, the cloud computing market was worth $368.97 billion in 2021 and will see a compound annual growth rate of 15.7% until 2030.

Next year, Microsoft plans to expand further in the lucrative market by investing in new data centers in at least 11 new regions, with the company "very bullish" about Asia as a "massive growth market."

Moreover, 2023 will see Microsoft flex its newly acquired digital advertising muscles after purchasing Xandr in 2021. The company has partnered with Netflix to exclusively provide ads on its ad-supported streaming tier, which launched in November. The new year will allow more time for Microsoft to start reaping the rewards of the $190 billion digital advertising industry, which is expected to hit $362 billion by 2027.

Microsoft's primary strength is its diversity. In addition to cloud computing and advertising, the company holds strong positions in gaming, operating systems, and enterprise resource planning with its Microsoft 365 subscription-based services.

Despite a year of economic hardships, the tech giant reported an 11% year-over-year revenue rise of $50.1 billion in its latest quarter, while operating income grew 6% and hit $21.5 billion. Along with $63.33 billion in free cash flow as of Sept. 30 and the funds to continue investing in its business despite further economic declines, I wouldn't bet against Microsoft's stock in 2023.

2. Alphabet

With a leading 28% market share in digital advertising, Alphabet stands to gain the most from the industry's projected growth. However, its dominant position in the market has caused its stock to fall 37% since January. Rises in inflation and interest rates in 2022 have tightened the budgets of many businesses, with advertising one of the first things to go. 

However, economic headwinds are temporary, and its plummet in share price doesn't seem to reflect Alphabet's financials. In the third quarter of 2022, revenue rose 6% year over year to $69 billion, with operating income reaching $17.1 billion. While segments such as YouTube ads and Google Network saw slight declines and search, advertising, and services marginally grew between 2.4% to 4.2%, the quarter's brightest spot was the company's Google Cloud segment, which increased 37.6% to $6.8 billion.

Alphabet has taken hits from poor macroeconomic conditions in 2022, but its business has continued to grow regardless.

Looking at the bigger picture, Alphabet's revenue has increased by over 88% since 2018, rising from $136.8 billion to $257.6 billion in 2021, and it is on track to beat those figures again in 2022. Meanwhile, its net profit has more than doubled from $30.74 billion to $76.03 billion in the same period.

With Alphabet's $62.5 billion in free cash flow as of Sept. 30, the metric is fairly on par with Microsoft. When comparing price-to-earnings ratios, Microsoft's sits at 26.06 while Alphabet's is 17.8, suggesting its current stock price offers more value.

Microsoft and Alphabet are home to robust businesses with considerable market share in some of the world's most profitable industries. They've each faced an economically challenging year yet managed to report financial growth. As a result, both companies' stocks would be an asset to any portfolio, likely to offer sustained growth over the long term.

However, if you can only choose one, I'd go with Alphabet's stock at its current position. Its harder fall in share price has made it more of a bargain and a better buy going into 2023.