DALLAS (AP) — Exxon’s profit keeps shrinking because of lower oil prices, and the company is responding by sharply cutting investment in future production.

Exxon Mobil Corp. said Friday that its third-quarter income fell 38 percent from a year ago to $2.65 billion.

It marked the eighth straight quarter in which Exxon’s profit fell compared with a year earlier.

Still, it was the company’s best quarter this year, and the profit was higher than analysts had expected, although revenue was sharply below forecasts.

Chairman and CEO Rex Tillerson said the business environment for his company “remains challenging.”

Oil prices hit longtime lows early this year but have recovered somewhat since then to around $50 a barrel. Exxon said, however, that if average prices don’t improve by year-end it may have to reduce its count of proved reserves by up to 4.6 billion barrels. The disclosure indicates that nearly one-fifth of Exxon’s reserves, mostly in Canada, might not be economical to pump from the ground at those prices.

Exxon said it will examine whether to write down the value of the assets.

Such a write-down wouldn’t cost Exxon any cash and would be “more symbolic than anything else,” said Brian Youngberg, an analyst with Edward Jones. Investors would look beyond the accounting change, and Exxon could produce the oil if prices rise, he noted.

Exxon and other oil companies are cutting capital spending as they ride out the slump in crude prices that began in mid-2014. Exxon invested $4.19 billion in the latest quarter, down 45 percent from its capital spending a year earlier. So far this year, Exxon has cut more than $9 billion in production investment.

Some analysts predict that those kinds of cuts will mean less oil and higher prices in coming years.

Exxon’s profit amounted to 63 cents per share, beating the forecast of 58 cents per share from 22 analysts surveyed by FactSet.

In a twist, the company’s chemicals division earned twice as much as the beleaguered oil and gas exploration and production business. Exxon pumped 3 percent less oil and gas from the ground, which the company blamed partly on interruptions to its operations in Nigeria because of fighting there.

Costs dropped 10 percent. Exxon saved more than $1 billion, or 75 percent, on income taxes.

Tillerson, the CEO, said the company delivered solid results in a challenging environment. He said the company was focused on efficiency, strategic investments, and shareholder value.

Lower profits are not Exxon’s only problem. Federal and state officials are challenging Exxon’s openness and accounting for the link between burning oil and climate change.

The company has gone to federal court in Dallas to limit or block investigations by New York and Massachusetts state officials into whether the company hid what it knew about oil’s role in climate change.

The Securities and Exchange Commission is probing how Exxon values its assets given the prospect of tougher regulations to limit climate change.

Exxon has called the state investigations politically motivated and an illegal attempt to silence the company from talking about climate change.

In afternoon trading, shares of Irving, Texas-based Exxon fell $1.16, or 1.3 percent, to $85.76. They are up 4 percent over the past year.