"If you aren't willing to own a stock for ten years, don't even think about owning it for ten minutes." So says investing star Warren Buffett. In other words, one of the best ways to succeed in the stock market is to hold onto shares in companies with solid businesses for the long term. By doing so, you can safeguard yourself from short-term economic declines and unexpected fluctuations in the market. 

Last year was a prime example as a sell-off saw declines in numerous stocks. However, companies with the strongest businesses will, no doubt, be able to navigate this challenging time and come out ahead. So without further ado, here are two top stocks you can buy in 2023 and hold indefinitely. 

Apple 

Apple (AAPL 0.52%) is one of the easiest stocks to recommend in light of the almost unwavering demand for its products and a swiftly expanding services business. The company's stock is down 23% year over year after a sell-off in 2022. However, Apple isn't so bad off when noting the 33% to 39% stock declines that its peers, such as Alphabet and Amazon, experienced in the same period. 

Last year, macroeconomic headwinds highlighted the strength of Apple's business with consistent demand for its products. For instance, in the third quarter of 2022, global PC shipments for the industry fell 15%. However, Apple reported the only growth among its competitors -- up 40.2% during the period.

While the company's hardware remained in demand, its services business continued to boom. In fiscal 2022, services revenue increased 14% year over year to $78.1 billion, while iPhone revenue rose by 7%. Additionally, services reported a 71.7% profit margin, while products came in at a 36.3% profit margin.

Apple proved the resilience and reliability of its business in an economically challenging year. Its stock price has grown 203% in the last five years despite a recent sell-off. Apple has multiple, highly anticipated products that are expected to be released in 2023 and continuing growth in its services. As a result, its stock is a screaming buy this year and one you can hold forever. 

Microsoft 

Like Apple, Microsoft (MSFT -2.45%) is a company that fared better than its competition in 2022, proving its stock would be an asset in any portfolio over the long term. The company's shares are down 25% year over year. However, those who bought the stock five years ago have still retained a 167% return on their investment thanks to the tech giant's stellar growth.

The company's biggest strength is its priority on diverse revenue streams. As the home to such brands as Windows, Office, Xbox, Azure, and LinkedIn, the company has carved out dominating positions in operation systems, productivity software, video games, cloud computing, and social media. As these markets continue to grow annually, so does Microsoft's revenue.

Moreover, the company's diversity kept its business growing in 2022 despite hits to the PC market. In fiscal 2023's first quarter, ended Sept. 30, Microsoft reported revenue growth of 11% year over year to $50.1 billion, with operating income rising 6% to $21.5 billion despite operating losses of 15% in its more personal computing segment.

Microsoft's earnings growth primarily came from businesses less affected by economic headwinds, such as subscription-based productivity services like LinkedIn and Office as well as its cloud computing platform, Azure. In Q1 2023, productivity processes saw revenue grow 9% year over year to $16.4 billion, with operating income increasing 10%. Meanwhile, its intelligent cloud segment enjoyed revenue growth of 20% to $20.3 billion, with operating income rising 17% to $8.9 billion.

In 2023, moves such as expanding Azure data centers to 11 new regions, growing its digital advertising business with a Netflix partnership, and boosting its gaming division by potentially acquiring Activision Blizzard are only further reasons to buy Microsoft stock. It's an ever-expanding company and a stock you can buy in 2023 with plans to hold forever.