An investing theory has developed around buying stocks that get booted from the Dow Jones Industrial Average or the S&P 500 because they tend to go on and outperform both the indexes and the companies that replaced them in the immediate aftermath of the shakeup. ExxonMobil (XOM -0.01%) is a case in point.

The oil and gas giant was kicked off the Dow in August 2020, and one year later, it beat the index with a total return of 37% to 29%. Exxon has gone on to open a dramatic lead over the Dow in the years since, with its total return more than tripling in value versus the index, generating a 25% total return for investors.

In its just-released fourth-quarter earnings report, the energy behemoth explains why it has become such a stellar stock and why it's more than just the current conditions being favorable to the industry.

Person with a hard hat full of money.

Image source: Getty Images.

A gusher of profits

Exxon just posted its best year for profits in the oil company's 135-year history, generating earnings of $55.7 billion, making it one of the most profitable stocks on the market (only Apple and Microsoft are better, so far).

While rising gas prices that were exacerbated by Russia's invasion of Ukraine were certainly a large contributing factor in Exxon's performance, and excluding impairments related to its withdrawal from its Sakhalin-1 oil fields off Russia's Sakhalin Island, adjusted profits were $59.1 billion. There were other factors involved, ones that point to future profitability potential.

Chairman and CEO Darren Woods pointed to years of under-investment in production by the industry, causing supply to be constrained. Oil and gas companies won't be able to meet the outsized demand from its collapse during the pandemic over the coming years.

Crude supplies have been depleted, and natural gas inventories have been reduced, a situation that has only worsened with Europe's concern over where it will get its needed energy.

Pricing for both is well above their 10-year historical averages, and refining margins have soared because of the large numbers of refineries that were closed during the pandemic. The last refinery with significant downstream capacity in the U.S. was built in 1977. Despite smaller refineries having come online since then or other facilities expanding their capacity, there have not been nearly enough to match demand.

Going against the grain

The energy giant was able to capitalize on the current conditions because it zigged when other industry players zagged. Woods said, "of course, our results clearly benefited from a favorable market, but to take full advantage of the undersupplied market our work began years ago, well before the pandemic when we chose to invest counter-cyclically."

Exxon invested heavily in its core businesses, like its refining business with projects in the Netherlands and Texas; in liquefied natural gas (LNG) export facilities around the world, such as in Mozambique, where it began shipping in November its first cargos from the Coral South project; and in new production in the Permian Basin and the vast oilfield off the coast of Guyana, where it is the lead operator.

Exxon says it will invest between $20 billion and $25 billion annually in Guayana through 2027, which it believes could produce as much as 1 million barrels of oil per day by the end of the decade.

Worker and oil derrick at sunrise.

Image source: Getty Images.

Sharing the wealth

Being farsighted, though, has come at a cost. Despite the need for more energy, Europe has slapped windfall profits taxes on oil companies, and Exxon paid $1.3 billion from fourth-quarter earnings.

CFO Kathy Mikells told Reuters that windfall profit taxes are "unlawful and bad policy" because they create disincentives to invest, causing "the opposite effect of what you are trying to achieve." Exxon is suing the European Union because the taxes go beyond its legal authority.

Yet, with operating cash flows rocketing 60% higher this year to $76.8 billion, it spent $30 billion on stock buybacks and dividends last year. It expects to repurchase $35 billion's worth of stock over 2023 and 2024. Exxon also increased its dividend 3% last year, the 40th consecutive year the payout has risen.

With global structural imbalances between supply and demand, a head start years in the making of investments to narrow the gap, and sharing its success with its shareholders, ExxonMobil is an integrated oil and gas stock that still has many years of growth ahead of it.