With the stock market recently down more than 20% from its 52-week high, qualifying as a bear market, smart investors know that such circumstances tend to offer many terrific investment opportunities in the form of great companies with their stocks on sale.

Here are three such companies to consider for your long-term portfolio. It's important that it's your long-term portfolio because the stock market is especially unpredictable in the short term; even great stocks can fall further over the coming year, for example. But over the long run, undervalued great stocks tend to do well.

1. Microsoft

Let's start with Microsoft (MSFT -0.66%), a very familiar name with a stock price that was recently off 29% from its 52-week high. That alone doesn't necessarily mean it's a bargain now, but when you see that its recent price-to-earnings (P/E) ratio is 26, well below its five-year average of 36, with similar other valuation metrics, then it does look rather attractively priced.

Microsoft is a huge company. Even with that 29% drop in its share price, its market value was recently $1.8 trillion. It's home to a host of impressive businesses, such as the Windows operating system and the Microsoft 365 suite of productivity software, including Word, Excel, and Outlook, among other applications.

It also offers investors the Azure cloud-computing platform (with about a fifth of the market share for cloud infrastructure services), Surface devices, Xbox gaming systems, Skype, and LinkedIn. A promising recent move has been transitioning some of its products (such as Office and Xbox) to a subscription model, which will generate rather reliable recurring income.

Microsoft is also a dividend-paying stock, with a recent yield of 1.11%. That payout has been growing by an annual average of about 10% over the past five years. Microsoft itself is growing well, too, with third-quarter revenue up 11% (16% in constant currency) year over year, though its momentum has been slowing recently.

2. MercadoLibre

MercadoLibre (MELI -0.00%) is far less well known, but it's also been a powerful grower over many years, increasing in value by about 1,000% over the past decade -- roughly 27% annually, on average. Its stock was recently down 38% from its 52-week high and sitting at a market value near $42 billion.

What does the company do? Well, it's often referred to as "the Amazon.com of Latin America," and it has a lot in common with PayPal, too, operating an e-commerce market in 18 countries and a digital payment system, Mercado Pago, as well. In its own words, "MercadoLibre hosts the largest online commerce and payments ecosystem in Latin America."

That word "ecosystem" should pique the interest of investors, because ecosystems, where multiple products and services of a company are intertwined, can be a valuable competitive advantage. Apple has built a huge ecosystem, for example, with its iPhones, Apple Watches, Apple Pay and other offerings all working well together.

In MercadoLibre's third quarter, total revenue popped 60% year over year, while the company's fintech business saw total payment value rise 76% on a currency-neutral basis. The company seems to have a lot of room for growth, and buying it in 2023 is likely to pay off well for long-term investors.

3. Meta Platforms

Meta Platforms (META -1.12%), formerly known as Facebook, has a new name to reflect the fact that it encompasses more than Facebook -- although the social media juggernaut is by far its most important property. The company's stock was recently down 66% from its 52-week high, and its P/E ratio was recently 11.4, well below its five-year average of 25.8.

It's a compelling business, as Facebook boasts 2 billion daily active users, and 3.7 billion people recently used one or more of its family of businesses each month. (Those businesses include Messenger, Instagram, and WhatsApp.)

So why is Meta's stock down so much? Well, there's uncertainty. It's among the companies being looked at by antitrust regulators, and it's investing heavily in the metaverse, which may or may not reward the company handsomely in the future. On the other hand, it may benefit greatly if TikTok is banned in the U.S., which could happen.

Meta Platforms is facing some challenges, but it also has a lot going for it, in large part due to its massive reach -- if it can monetize more of those billions of people.