CEO Warren Buffett called Apple (AAPL -0.35%) "a better business than any we own" at Berkshire Hathaway's (BRK.A -0.76%) (BRK.B -0.69%) annual shareholder meeting last May. The stock is, by far, the largest holding in Berkshire's portfolio, a sign of Buffett's conviction in the company. Yet the Oracle of Omaha decided to sell nearly $2 billion worth of Apple shares at the end of last year.

Berkshire Hathaway held 10 million fewer Apple shares at the year's end than in September, according to the company's 13-F filing with the Securities and Exchange Commission. But investors shouldn't start worrying Buffett has soured on the tech titan. There's a clear explanation as to why Buffett sold some of his Apple stock.

Close-up of Warren Buffett.

Image source: The Motley Fool.

Apple's not the only stock Buffett sold last year

Buffett sold a lot of stocks in 2023. Through the first nine months of the year, Berkshire Hathaway sold $32.8 billion worth of stock (and bought just $9.1 billion).

Buffett had plenty of good reasons for trimming some positions and exiting others entirely, but it's impossible to ignore the tax consequences of Buffett's sales.

While Berkshire Hathaway reports deferred income taxes on the unrealized gains in its portfolio as a liability on its balance sheet, it doesn't actually have to pay those taxes until Buffett or one of the other investment managers at Berkshire sells shares and realizes a gain. As of the end of September, Berkshire's deferred tax liability was about $85 billion. It had $207 billion in net unrealized gains, and stock sales earlier in the year generated $5.4 billion in realized gains.

Buffett continued selling in the fourth quarter. Two of the biggest sales were HP and Paramount Global.

He slashed 78% of Berkshire's remaining position in HP, a move Buffett started to make in the third quarter. That stock sale likely came with a hefty loss, as HP shares have declined in value since Buffett first established the position.

Buffett cut one-third of Berkshire's position in Paramount. That represents another big loss from his initial stake established in 2022 when the stock traded above $30 per share.

Needless to say, Buffett's investments in these two companies didn't work out as expected. And he's not afraid to admit defeat when he's wrong or own up to a mistake. Plus, the sale of the two losing positions resulted in significant losses that can count against gains in Berkshire's portfolio.

So, in order to take advantage of the losses, Buffett looked to take gains on some of his winning positions. Apple is one of his biggest wins. So, it makes sense that he took just enough gains to offset the losses from other stock sales, resulting in a minimal net realized gain and a small tax bill as a consequence.

Did Buffett make a mistake selling Apple?

This isn't the first time Buffett's sold shares of Apple at the end of the year.

He sold shares at the end of 2018, 2019, and 2020, very likely taking gains each time. The sales were done purely for tax purposes. But Buffett said the decision to sell Apple shares was "probably a mistake" during Berkshire's 2021 annual meeting. When he asked Vice Chairman Charlie Munger if he thought it was a mistake, too, he simply replied, "Yes!"

Buffett looked to correct his error by buying more Apple shares in 2022 as stock prices declined. Still, he missed out on significant gains by selling Apple. Shares reached a new all-time high last year.

Buffett may have just repeated his mistake. That said, last quarter's sale isn't nearly as big as his sale in 2020. The 10 million shares he sold represent about 1% of Berkshire's total position. If it does turn out to be a mistake, it'll be a much smaller one. What's more, Buffett has an opportunity to buy back those Apple shares at a lower price, after the company's stock dropped to start the year.

Apple shares currently offer relatively good value. They trade at 27.8 times analysts' consensus estimate for 2024 earnings and just 25.5 times expected earnings in 2025. While that's a premium to the overall market, Apple shares arguably deserve a premium thanks to the generous capital return program and the $100 billion per year the company generates in free cash flow.

The important lesson for investors is that there are many reasons an investment manager might sell a stock. It doesn't necessarily mean they no longer like the company or they think it's not a good value. And in the case of Buffett's take on Apple, he's betting about $165 billion it's a great investment.