Fossil fuels are out of style, according to conventional wisdom. Renewable sources of energy are where the future lies. And it's where a lot of investing dollars are flowing.

But Warren Buffett has never been afraid to go against the crowd. That's exactly what he's doing now. The Oracle of Omaha has led Berkshire Hathaway (BRK.A -0.76%) (BRK.B -0.69%) to invest heavily in oil and gas companies.

Buffett has two big reasons for betting more than $40 billion on fossil fuel stocks.

Breaking down Buffett's big bet

Let's first look at how Buffett is making such a big bet. More than half of the total -- around $21.5 billion -- is the current value of Berkshire's stake in Chevron (CVX 0.37%). The oil and gas giant ranks as Berkshire's fifth-largest holding

Buffett's favorite oil stock these days, though, appears to be Occidental Petroleum (OXY -0.15%). Berkshire has aggressively bought shares of Occidental since last year. It now owns over 25% of the company, with its position valued at around $14.2 billion. The conglomerate has regulatory approval to acquire up to 50% of Occidental.

Occidental isn't the only oil stock that has caught Buffett's eye recently. Berkshire also initiated a small stake (at least, a small one for Buffett) in Vitesse Energy (VTS 0.75%) in the first quarter. That investment is now worth close to $1.2 billion.

Earlier this month, Berkshire Hathaway Energy agreed to buy a 50% stake in a liquefied natural gas facility for $3.3 billion. This deal brings the total of easily quantifiable investments Buffett has made in businesses with fossil fuel ties to over $40 billion. The actual amount is even greater since Berkshire Hathaway Energy also owns 21,200 miles of natural gas pipelines.

Two key factors

So why is Buffett betting so heavily on fossil fuels? I think the answer boils down to two key criteria he uses to make any investment decision.

Buffett wrote in his 2013 letter to Berkshire Hathaway shareholders that he and longtime business partner Charlie Munger look at two things before buying a stock or an entire business. First, they attempt to estimate the earnings range for a company for at least five years in the future. Second, they determine if the company's valuation is reasonable compared to the low end of that projected earnings range.

Many believe that the fossil fuels industry is going the way of the dinosaurs. Buffett, however, seems to think that there are years of strong earnings power left for oil and gas companies. He told CNBC's Joe Kernen in an interview earlier this year that at least the same amount of oil and possibly more will be produced five years from now. Buffett also sounded optimistic about the opportunities for companies such as Occidental in carbon capture and sequestration.

As for valuations, the energy sector is the cheapest sector in the entire S&P 500 right now. The energy stocks in Berkshire's portfolio underscore this. Chevron's forward price-to-earnings ratio is around 12. Occidental's shares trade at less than 15 times forward earnings, even after skyrocketing close to 120% since the beginning of last year. Vitesse Energy appears to be the biggest bargain, with a forward earnings multiple of under 3.

A smart bet?

Buffett would be the first to admit that he's made his fair share of mistakes. However, when he goes big with an investment, it tends to pay off. 

Sure, renewable energy is likely to cause the demand for fossil fuels to decline over the long term. But the process could take decades. Some fossil fuels, especially natural gas and natural gas liquids, could enjoy greater demand. 

Buffett seems to recognize that many investors have prematurely discounted the earnings power of oil and gas companies. I think he's making a smart contrarian bet.