Exxon Mobil Corp. earned 18% less than a year ago, but the energy behemoth showed signs of ending its yearslong slump in oil and gas production.

The Irving, Texas, conglomerate posted $7.9 billion in profit in the third quarter, down from $9.6 billion a year ago, in large part because of a steep decline in profit from refining oil into gasoline and diesel.