Occidental Petroleum Corp. on Aug. 2 capped a turnaround with a second-quarter profit that topped Wall Street estimates while slashing debt and launching a share buyback program on the back of strong oil and gas prices.

Occidental has shed much of the debt it took on in 2019 to buy rival Anadarko Petroleum before the COVID-19 pandemic cratered oil demand. In the second quarter, it paid down $4.8 billion in debt and launched a $3 billion share repurchase program.

The Houston-based energy company posted an adjusted profit of $3.2 billion, or $3.16 per share, topping the $3.07 per share estimated by analysts tracked by Refinitiv IBES.

The company said it spent $1.1 billion to buy back shares through Aug. 1.

Occidental’s strategy of pumping oil while it develops technology to reduce carbon emissions from fossil fuels gained a vote of confidence after Warren Buffett’s Berkshire Hathaway Inc. began snapping up Occidental shares in recent months.

Berkshire now has a 19.5% stake in Occidental, just below the threshold at which it could choose to book some of the oil company's earnings as its own.

Occidental’s share price has more than doubled this year, hitting $65.06 on Aug. 2, as the company benefits from rising oil and gas prices following Russia’s invasion of Ukraine.

Oil prices were up 17% from the first quarter, boosting Occidental’s upstream earnings more than five times over the year ago, to nearly $4.1 billion.

Occidental’s chemicals business posted an $800 million operating profit. Its pipeline and marketing unit posted a $264 million profit, compared with a $30 million loss a year ago.

“The company has shifted from debt reduction to shareholder returns,” said Peter McNally, an analyst at research firm Third Bridge.

One of the top producers in the prolific Permian Basin of West Texas and New Mexico, Occidental produced 1.14 million boe/d in the second quarter, within its guidance, but 32,000 boe/d less than the prior quarter. The company has been facing higher costs in the Permian, the main U.S. unconventional basin.