The Gulf of Mexico oil spill continues to plague BP more than two years after the disaster as the company has revealed another $847m (£538m) hit to cover rising legal costs.

The additional charge for the second quarter brings the total bill for the fatal Deepwater Horizon incident to $38bn, BP said.

BP is struggling to shake off the reputational blow of the April 2010 Macondo blow-out after recently coming under further fire in a report from a US government safety panel.

And the underlying picture at BP is not much brighter, as the company revealed a 24% slide in underlying replacement cost profit to $8.5bn in the first half of the year as oil prices fell and maintenance work disrupted production.

The BP group chief executive, Bob Dudley, said: "We recognise this was a weak earnings quarter, driven by a combination of factors affecting both the sector and BP specifically."

The group's production also continues to suffer from the drilling ban imposed on it in the wake of the Gulf of Mexico spill, while it is also ramping up asset disposals under a programme to sell $38bn (£24.4bn) of assets by 2013.

It has entered into agreements to sell assets with a value of $24bn (£15.3bn) since 2010.

BP's production of oil and gas, excluding results from its Russian joint venture TNK-BP, averaged 2.27m barrels of oil per day in the second quarter, compared with 2.46m for the same period last year, a slide of 7%.

The oil giant warned that production was expected to slide lower in the third quarter, between July and September, before returning to growth in the final three months of 2012.

The group also took a $4.8bn hit for writing down the value of a series of assets including US shale gas and its decision to suspend the Liberty project in Alaska – an offshore oil field with about 100m barrels of recoverable oil.

BP set up a $20bn trust to cover the costs of claims for the Deepwater Horizon incident, which is included within the $38bn provision.

BP had paid nearly $8.8bn by 30 June for individual, business and government claims, including payments made before the establishment of the trust.

A total of $7bn had been paid to individual and business claimants, while federal, state and local government authorities had received $1.4bn for claims and advances.

BP is facing a bid battle for its stake in TNK-BP, after Russia's state oil company Rosneft entered the fray just a week after TNK partner AAR confirmed it was interested in extending its stake.

Its plans to offload the TNK-BP stake follow a chequered history in Russia. An attempt by BP and Rosneft to buy out AAR last year for about £20bn – as part of an attempt to salvage their Arctic exploration tie-up – was blocked by AAR.

Shares in BP were down 3% after Tuesday's update was published.