What happened

Shares of ExxonMobil (XOM -1.17%) delivered sizable gains for investors last month as the oil major benefited from rising oil prices and a strong third-quarter earnings report.

According to data from S&P Global Market Intelligence, the stock finished the month up 27%. As the chart shows, the stock gained early in the month as oil prices bounced from a months-long slide, and Exxon closed out the month with further gains after it raised its dividend and reported huge profits in its third-quarter earnings report.

XOM Chart

XOM data by YCharts

So what

Exxon's stock soared through the first week of the month as reports came in that OPEC+, which also includes Russia, was considering an output cut in order to raise the price of oil. 

After oil prices spiked when Russia first invaded Ukraine in February, prices for the commodity had come down in recent months, dipping from $120 a barrel to $80 a barrel. Then, following days of rumors lifting oil prices, the group announced a production cut of 2 million barrels a day.

The following week, Exxon announced a carbon-capture project with CF Industries and EnLink Midstream, and the company also continued to move forward with its strategy of selling underperforming assets, selling a Montana refinery and some pipelines to Par Pacific for $310 million.

Finally, Exxon reported strong third-quarter earnings on Oct. 28, lifting the stock 3%, after it said quarterly profits nearly tripled from a year ago to $19.7 billion, or $4.45 per share after adjustments. That easily beat expectations at $3.79. The company also raised its dividend by 3% to $0.91, maintaining its streak of 40 consecutive years of dividend increases.

CEO Darren Woods said, "Rigorous cost control and growth of higher-margin petroleum and chemical products also contributed to earnings and cash flow growth in the quarter."

Now what

ExxonMobil has been a big winner this year, with the stock up 86% while the S&P 500 is down 20%. Elevated oil prices have been good for Exxon and the rest of the oil and gas sector, but investors should keep an eye on the overall economy, as oil prices are likely to fall in an economic downturn. 

With much of the world experiencing high inflation and rising interest rates, there could be a global recession in 2023. For now, though, Exxon's profits are hard to beat.