It's hard to throw shade on a company that more than doubled its year-over-year earnings, which is what ExxonMobil (XOM 1.15%) achieved in the first quarter of 2023. And yet this energy giant might not be the best way to play the oil sector over the short term, even though it would be a good way to gain exposure to the energy sector over the long term. 

What a quarter?

In the first quarter of 2023, Exxon posted earnings per share of $2.79, up from $1.28 in the same period of 2022. You don't need a calculator to see that it was a more than 100% year-over-year earnings increase. That's pretty impressive.

And yet the energy giant's top line actually fell from $90.5 billion in the first quarter of 2022 to $86.6 billion this year. The bottom-line difference was partly related to higher costs in the year-ago period and a one-time charge.

Two people working on a drilling rig for an oil well.

Image source: Getty Images.

Also helping things along in the first quarter of 2023 was a year-over-year increase in production. That's good from an operational standpoint, but that was offset somewhat by lower realized commodity prices. And that's where the big risk comes in for investors today.

While the first quarter of 2023 was a huge improvement over the first quarter of 2022, it was the second quarter in a row that earnings have declined. In the third quarter of 2022, Exxon's earnings per share totaled $4.45, then dropped to $3.40 in the fourth quarter, and as already noted, settled to $2.79 in the first quarter of 2023. The downtrend has been largely driven by falling energy prices.

A divergence

Production growth is good news. And Exxon has also been able to keep its production costs low, another important long-term plus. However, energy prices are still the most important driver of the company's earnings statement. And history has shown very clearly that the energy sector is prone to material price swings as commodity prices rise and fall, often swiftly. 

XOM Chart

XOM data by YCharts.

This time around, however, Exxon's stock hasn't tracked along with that of its closest peer, Chevron (CVX 1.54%), even though its sequential earnings declined again. In fact, even as the price of oil has fallen, Exxon's share price has continued to head roughly higher. That suggests that there might be a near-term risk of a more-material price pullback if investor sentiment sours on the energy sector.

And yet, you can't underestimate Exxon's improving production and low costs. Nor should you ignore its incredibly strong balance sheet, which is among the least leveraged of its integrated energy major peers. In fact, the roughly 0.2 times debt-to-equity ratio provides Exxon ample leeway to deal with the next energy downturn while continuing to both fund its business and its dividend.

In this way, investors looking to add long-term energy exposure to their portfolios should be attracted by the company's resilience, proved by over four decades of annual dividend increases.

What to do

If you are buying Exxon because of its big year-over-year earnings improvement, step back and consider the sequential trend in what is a highly commodity-driven business. Unless you expect oil prices to bounce back toward their recent highs, the recent relative strength of Exxon's stock is probably a bigger downside risk than is worth taking on.

But if you are trying to diversify your portfolio by adding a reliable dividend-paying energy stock, then Exxon and its 3.3% dividend yield might be worth a deep dive. That said, Chevron offers a higher yield right now (3.8%), a similarly strong balance sheet, and just as impressive a dividend history.