Shares of oil producers ExxonMobil (XOM 1.05%) and Pioneer Natural Resources (PXD 1.23%) and oil field services giant Baker Hughes (BKR 0.27%) rallied in March, up 11.2%, 11.6%, and 13.2%, respectively, according to data from S&P Global Market Intelligence.

Global tensions, falling U.S. gasoline stocks, and widening refiner crack spread all contributed to the favorable oil and gas environment in March, continuing the upturn since the beginning of the year. Exxon also announced a new oil discovery and progress in its regulatory process to acquire Pioneer.

Oil prices are rising again

Exxon is the largest diversified oil major in the world outside of Saudi Aramco, and Baker Hughes is the second-largest oilfield services firm. Thus, each stock tends to move with the general outlook for oil prices.

That outlook has been looking up of late. On March 3, OPEC+ announced it would extend its voluntary additional 2.2 million barrels per day of production cuts -- first announced about a year ago -- through the second quarter of 2024.

Meanwhile, tensions in the Middle East continued to escalate between Israel and Iran and Yemen, which has the potential to further disrupt Iranian and other Middle East fuel exports. And Ukraine also began attacking Russian oil refineries last month.

So the OPEC+ cuts, even in the face of increasing geopolitical tensions, put a lid on supply, even as the U.S. economy remains strong and unemployment remains low. That's perhaps why total U.S. gasoline stocks fell from 239.7 million barrels on March 1 to 222.6 million barrels on March 31. And conventional gasoline stocks fell from 16.2 million barrels to 13.9 million barrels in that time, according to the U.S. Energy Information Administration.

Finally, Exxon is also one of the world's largest refiners. The month of March saw a continued widening of 3-2-1 crack spreads, which measure the margins refiners make on processing and selling gasoline and diesel fuel. These widening margins were also due to the same geopolitical tensions and a strong U.S. economy.

Oil field worker in front of a land-based oil rig.

Image source: Getty Images.

In terms of positive company-specific news, Exxon announced the discovery of a new oil deposit last month. On March 15, the company announced a discovery at its "Bluefin" site, nearly a mile underwater in the Stabroek block off the coast of Guyana. Bluefin joins another 30-plus discoveries made in the block since 2015 for the oil-producing giant.

The good news on Exxon also filters down to Permian Basin-based Pioneer, which Exxon agreed to acquire last October in an all-stock deal. Since the merger is an all-stock deal, positive news for Exxon filters down to Pioneer should the merger go through.

Speaking of the merger, on March 7, an Exxon vice president announced the company had submitted some million pages of documents required by the Federal Trade Commission's (FTC's) second review stage and that Exxon plans to close the deal sometime in the second quarter. So, these two giant companies should merge soon.

Finally, all this good news for oil prices is good news for oil field services companies, too, as oil companies will invest in new production only if prices warrant investment in expansion. On that note, Baker Hughes announced that U.S. shale drillers had increased their rig count by six in March and more than a dozen since mid-February amid rising oil prices.

More shale field activity would certainly help Baker Hughes' revenues and earnings.

Perhaps the best hedge against geopolitical tensions

Warren Buffett has been buying into various oil and gas stocks amid rising geopolitical tensions over the past few years. But most major companies across the sector would make good hedges against the breakout of wars abroad.

Moreover, traditional energy stocks tend to trade at lower multiples with higher dividends than many other sectors, allowing investors to get a decent yield on those hedge-like positions. As March showed, oil and gas stocks can help balance against your portfolio's other economically sensitive and/or oil-consuming companies.