With few exceptions, when Warren Buffett or one of his investing lieutenants, Todd Combs or Ted Weschler, buy a stock through Berkshire Hathaway's (BRK.B -0.69%) (BRK.A -0.76%) portfolio, they do so with the intention of holding it for the long haul. Buffett himself has often mused that his "favorite holding period is forever," and he places outsize focus on buying shares of high-quality businesses at fair prices.

With that in mind, here are three top stocks in Berkshire's portfolio that I believe are worth buying and holding for the long haul.

An e-commerce and cloud computing giant

Warren Buffett has previously lamented that he didn't invest in Amazon.com (AMZN 3.43%) earlier. But it's still telling that he finally opened a position in the e-commerce and cloud computing giant in early 2019 -- even if it was at the behest of his investing lieutenants. As of June 30, Berkshire owned around 10.55 million shares of Amazon, worth $1.41 billion and making it the portfolio's 23rd-largest position out of 55 stocks.

What's most incredible to me is that Amazon has had so little trouble continuing to grow both revenue and profits at scale. Shares of Amazon surged earlier this month after the company handily exceeded its own guidance and Wall Street's estimates, with second-quarter revenue climbing 11% year over year to $134.4 billion, translating to net income of $6.7 billion, or $0.65 per share. That's compared to a loss of $0.20 per share a year earlier.

Amazon's operating income also more than doubled on a year-over-year basis last quarter to $7.7 billion, helped by 12% growth in its lucrative Amazon Web Services (AWS) cloud-computing division. Notably, Amazon CEO Andy Jassy confirmed that growth from AWS had "stabilized as customers started shifting from cost optimization to new workload deployment" during the quarter.

Though shares of Amazon are now up around 56% year to date, it also remains well below its 2021 highs -- and I believe this is a winner that can keep on winning for years to come.

A surprising tech holding

Arguably the most surprising tech holding in Berkshire's portfolio is cloud-based data warehousing specialist Snowflake (SNOW 3.69%) -- so named by its founders in 2012 because snowflakes are "born in the cloud."

Berkshire bought around $250 million worth of Snowflake stock at its initial public offering (IPO) price of $120 per share (or just over 2.08 million shares) in September 2020, then spent roughly another $1 billion to purchase an extra 4.04 million shares from another stockholder at Snowflake's debut price of around $254 per share.

Both were out-of-character moves for Buffett, who has often noted his distaste for buying shares of companies around their public debuts -- spurring speculation that it was his investing lieutenants who made the buys. In any case, Berkshire still owned those roughly 6.125 million shares of Snowflake as of June 30, worth a little over $900 million today -- good for approximately 0.3% of its roughly $349 billion portfolio and making Snowflake its 29th-largest holding out of 55 stocks.

That raises another question, however: Why has Snowflake fallen so far from its peak (at one point trading above $392 per share in late 2021) to now trade so close to its original IPO price?

First, Snowflake was one of many richly valued tech stocks that pulled back hard over the past two years. The broad-based plunge came amid a combination of rising interest rates and macroeconomic headwinds that have made raising capital more difficult for yet-to-be-profitable businesses, which previously had free reign to prioritize top-line growth while forsaking bottom-line profits.

Indeed, while Snowflake saw revenue climb an incredible 48% year over year (including 50% growth in product revenue) to $623.6 million last quarter, that growth translated to a harrowing net loss of $225.6 million.

What's more, Snowflake's latest full fiscal year 2024 (ending Jan. 31, 2024) outlook calls for a significant deceleration to 34% growth in product revenue to $2.6 billion. Naturally, the market won't demand nearly as high a valuation premium for a lower-growth company.

So why, then, do I think Snowflake is worth buying and holding now?

It helps that it's a cash-generating machine, and I believe the company is beginning to show signs of enjoying meaningful operating leverage as it scales. Snowflake only achieved its first-ever year of cash flow positivity two years ago, with adjusted free cash flow (FCF) of $150 million in fiscal 2022.

Fast forward to today, and we see that last quarter alone adjusted FCF climbed an impressive 46% to $286.9 million. Snowflake's latest guidance also calls for a full fiscal year 2024 operating income margin of just 5% and an adjusted FCF margin of 26%, or $676 million. I believe it's only a matter of time before Snowflake's operating leverage begins to translate not only to continued accelerated growth in cash flows but also to true sustained positive net income.

What's more -- keeping in mind Amazon's aforementioned commentary on AWS customers' shift from cost optimization to new workload deployment in recent months -- I think there's a decent chance Snowflake will deliver a positive earnings surprise relative to expectations when it reports fiscal second-quarter 2024 results next week (on Aug. 23, 2023).

A financial holding company with a familiar approach

Finally, Berkshire more recently (in May 2022) opened a position in mid-cap financial holding company -- and so-called "mini-Berkshire" -- Markel (MKL -1.00%). According to its most recent filings, Berkshire owned 471,661 shares of Markel valued at $704 million as of June 30, making Markel its 34th-largest holding at around 0.2% of Berkshire's total portfolio.

Similar to Berkshire, Markel follows a three-pronged approach to generate shareholder value consistently -- what the company calls its "three engines" of growth. Their approach includes, namely, its specialty insurance and reinsurance operations, its Markel Ventures group of diversified acquired businesses, and its own investment portfolio valued at around $8.4 billion as of this writing (where, ironically, Berkshire Hathaway stock is currently Markel's single-largest allocation at around 13% of the total portfolio).

Markel also boasts its own Buffett-esque renowned value investor at the helm in CEO and chief investment officer Tom Gayner, whom I've long considered an invaluable source of quotable investment wisdom since I personally bought shares of the company in 2009.

While many tech stocks have yet to reclaim their meteoric peaks from late 2021, Markel stock hit a fresh all-time high last week after posting exceptional second-quarter results on broad-based strength across each of its three engines.

Earned premiums from its insurance business climbed 11% year over year to $2.03 billion, while its combined ratio hovered at a healthy 93% (meaning Markel earned $7 for every $100 in premiums written). Net investment income grew 75% to $170 million thanks to higher interest rates, while net investment gains of $484.5 million reflected the increased value of its equity portfolio. Markel Ventures operating income grew 40%, thanks to higher operating leverage from its products businesses, which include Brahmin leather handbags, ornamental plant company Costa Farms, and many others.

That's not to say all three of Markel's engines will always fire on all cylinders going forward. But even then, when one of those engines sees weakness materialize for any given reason -- be it higher inflation, macro headwinds, or a market pullback -- relative strength from the other two tends to help pick up the slack.