What happened

While the broader markets were in negative territory Monday, shares of U.S.-based oil and gas exploration and production companies Occidental Petroleum (OXY -0.09%), Diamondback Energy (FANG 0.43%), and Battalion Oil (BATL -2.48%) were rocketing higher, up 3.1%, 5%, and 6.9%, respectively, as of 3:17 p.m. ET.

Unsurprisingly, the synchronous moves in these oil and gas stocks coincided with a rise in oil prices today, as West Texas Intermediate oil prices rose 4.1% as of the early afternoon, approaching $97 per barrel.

While investors continue to worry over demand as the economy weakens, Monday saw supply concerns growing from not one but several international suppliers in the Middle East. Combine that with last week's talk of OPEC+ potentially curbing output, and prices were rebounding today after a two-month sell-off.

So what

Oil prices had come down in recent months, not only on fears over a growth slowdown in the U.S. OPEC+ had decided to increase production, and there was the prospect for a nuclear deal with Iran, which would lift sanctions and bring Iranian barrels onto the market.

However, Monday saw at least two of those concerns reverse. Libya is currently experiencing sectarian tensions, with rival governments violently clashing over the weekend in a bid for power. Libya is a key supplier within OPEC+, and there are now worries that the country's oil production could be affected at some point. Additionally, while some had thought the Iran nuclear deal imminent, talks are now dragging on into September, with both sides taking time to think over a proposal put forth by the European Union.

Both of those supply concerns come on top of last week's surprise comment by Saudi Arabia that OPEC+ could cut supply growth in order to stem falling prices, even though oil prices remain high relative to the prior few years.

While a higher price would benefit Saudi Arabia, it would also benefit U.S. shale producers, most of which continue to ramp up production in a slow and controlled manner. If the rest of the world cuts back on production, U.S. oil and gas companies will continue to gain share and benefit from the higher oil price. That would help all U.S. producers, from Occidental, a large-cap and integrated oil major, which has operations across several U.S. basins as well as Oman and Algeria, to Diamondback, which is a large-cap U.S. pure play in the Permian Basin of West Texas, to Battalion, which is a small-cap producer that also operates in the Permian.

Now what

Oil stocks have been on a nice rebound over the past couple of months, after their stocks fell on recession concerns. However, most oil and gas companies have a lot going for them, including low P/E ratios, generous shareholder return programs, and, as was seen today, supply concerns from overseas producers.

Given how important oil and gas prices are to the global economy, it makes sense for investors to have some exposure to the sector. Not only do traditional energy stocks act as a hedge against potential supply shocks in the future, but most U.S. companies have now gotten serious about shareholder payouts.

During the "drill baby, drill" days of the shale oil revolution, most companies spent all of their cash flow on growing production, which led to years of oversupply and low prices. However, after bankruptcies and the demand shock during the pandemic, the industry has consolidated, with just about every major oil producer vowing to grow in a measured fashion, while paying out most free cash flow in the forms of dividends and share repurchases.

That change is likely why Warren Buffett has been buying up shares of Occidental hand-over-fist this year. Despite the volatility in oil and gas shares over the past couple of months, today is another reminder of why oil and gas stocks can help balance out the rest of a diversified portfolio.