London — BP bucked the trend of disappointing oil and gas earnings, beating expectations and increasing its cash flow as higher production offset the effect of lower energy prices.

The company’s performance brightens what has so far been a weaker-than-expected second quarter for Big Oil. While companies are more profitable today than they were at $100 crude after slashing costs, they were caught in recent months by falling natural gas prices. Total, Eni and Equinor all fell short of analysts’ estimates even as their output rose.

“What we have is solid performance in both upstream and downstream,” CFO Brian Gilvary said in an interview. In the last couple of years “we’ve had four of what I would call strong quarters. Everything is going well across the piece”.

London-based BP said adjusted net income was $2.81bn in the second quarter, compared with $2.36bn a year earlier. This exceeded even the highest analyst estimate, meaning the company has surpassed expectations in all but one of the previous 10 quarters, according to data compiled by Bloomberg.

“BP showed one of the best surprises of this quarter,” Ahmed Ben Salem, an analyst at Oddo BHF, said by phone. “Cash-flow generation is robust” and trading results were positive, although downstream came in below expectations, he said.

Shares of the company rose 3.4% to 545p as of 8.20am in London, the biggest increase in about six months.

Rising leverage

In April, BP paid the final cash installment for its purchase of US shale oil and gas fields from BHP Group. Those assets helped boost output, which rose 3.4% to 3.79-million barrels of oil equivalent a day in the quarter. That figure includes the contribution of Rosneft, the Russian oil company in which BP owns a nearly 20% stake.

The company said it expects third-quarter production to be lower due to seasonal maintenance activities in the North Sea, Angola and the Gulf of Mexico.

Cash flow from operations excluding payments related to the Gulf of Mexico oil spill — another key measure of whether the BHP deal is paying off — rose 17% from a year earlier to $8.2bn. On top of the payment for the US fields, BP also paid about $1.4bn in penalties associated with the 2010 Deepwater Horizon catastrophe.

That spending pushed a measure of company’s debt to the highest in at least a decade. Gearing, the ratio of debt to equity, was 31%, the third-straight quarter above 30%. BP will sell $4bn to $5bn of assets this year, part of a plan to complete $10bn in divestments by 2020 and use the proceeds to reduce gearing, Gilvary said.

Adjusted profit in BP’s refining, marketing and chemicals division was down 21% from a year earlier to $1.37bn due to significantly higher maintenance shutdowns, lower margins and weaker North American heavy crude differentials. That was partially offset by a stronger contribution from supply and trading, the company said.

BP said it expects a lower level of maintenance in the third quarter, but also predicted lower refining margins.