NEW YORK (AP) — Exxon Mobil reported $5.48 billion in profits during the first quarter as oil and gas prices rose steadily, more than doubling its profits compared with the same quarter last year.

But the oil giant took a huge hit as it abandoned its Russian operations due to the war, writing down $3.4 billion.

Including that loss, the oil giant reported profits of $1.28 per share Friday, which was well below expectations of analysts polled by Factset, who were looking for $2.23 per share.

Revenue at the Irving, Texas company was $90.5 billion, which far exceeded the $59.15 billion in revenue during the same quarter a year ago.

The price of oil climbed steadily during the first quarter after Russia invaded Ukraine, sending European countries which rely heavily on Russia for energy and others scrambling to find alternative sources for fuel. A barrel of the U.S. benchmark crude rose from $76 to nearly $130 per barrel before ending the quarter at $100, and drivers were filling up with increasingly expensive gasoline.

Natural gas prices rose too, climbing from $3.50 per million British thermal units to about $5.60, inflating home heating bills and electricity prices.

“As we think about recent events, our job has never been clearer or more important,” said Darren Woods, CEO, in a conference call with investors Friday. “The need to meet society’s evolving needs reliably and affordably is what consumers and businesses across the globe are demanding and what we delivered this quarter.”

As energy prices rose, Exxon’s stock price also was rising. The company announced Friday it’s expanding a program to repurchase its own stock, telling investors that Exxon could buy back up to $30 billion worth of its shares through 2023. It repurchased shares totaling $2.1 billion during the quarter, shelling out cash to investors as its stock price rose.

Exxon’s production fell to 3.7 million barrels per day of oil-equivalent, down 4% from the fourth quarter of 2021 due to weather-related unscheduled downtime, planned maintenance and divestments, the company said. Production in the Permian Basin grew and the company was on track to deliver a 25% increase in production there in 2022 compared to last year.

Exxon said it plans to eliminate routine flaring, the process of burning off what it considers excess natural gas, in the Permian Basin by the end of the year. Exxon also announced progress on carbon-reduction initiatives. During the quarter, Exxon secured the financing to expand its carbon capture facility in LaBarge, Wyoming and it announced plans to produce renewable fuel.

Shares of Exxon Mobil Corp. fell slightly during morning trading.

Also on Friday, Chevron reported a quarterly profit $6.26 billion, more than four times its earnings in the same period last year. On a per-share basis, profits from the San Ramon, California energy producer were a nickel short of Wall Street expectations, according to a survey by Factset, but Chevron does not adjust its reported results based on one-time events such as asset sales. And revenue surged 41% to $54.37 billion.