Tony Hayward had been criticised for his handling of the oil spill in the Gulf of Mexico Photograph: Win McNamee/Getty Images

BP today reported one of the largest losses in British corporate history because of the cost of the catastrophic oil spill in the Gulf of Mexico.

In its second-quarter results the company set aside $32.2bn (£20.7bn) to meet the cost of the clean-up, far higher than the City had expected and plunging the company into a $17bn loss. It made a profit of $3.1bn in the same quarter last year.

To pay for the mounting costs of the spill created by the explosion on the Deepwater Horizon rig on 20 April, BP plans to sell $30bn worth of assets – predominantly oil and gas fields – over the next 18 months.

The company also confirmed well-trailed reports that Hayward will receive a £1m payoff and a pension expected to be worth about half a million pounds a year.

The company's second-quarter results showed the full scale of the clean-up effort in the Gulf.

Since oil first reached the shore, a total of 836 miles of Gulf coast in Louisiana, Mississippi, Alabama and Florida have been affected. There have been more than 6,390 vessels (including skimmers, tugs, barges and recovery ships) and over 11m feet of boom deployed offshore to reduce the amount of oil reaching the shoreline.

The operations have recovered approximately 825,000 barrels of oily liquid. In addition, a 409 controlled burns have been carried out, removing an estimated 261,400 barrels of oil from the surface of the sea. In total, more than 40,000 people are involved across five states of the US.

The results also set out the flurry of legal proceedings that the spill has created. BP is the subject of a US department of justice investigation to determine whether US civil or criminal laws have been violated; a US presidential commission to examine the causes of the incident; a joint investigation by the US coastguard and the Bureau of Ocean Energy Management, Regulation and Enforcement (which until June 2010 was named the Minerals Management Service); an inquiry by the Securities and Exchange Commission and other investigations by US state and federal agencies including the US Chemical Safety and Hazard Investigation Board as well as the US Congress.

In addition, BP group companies are among those named as defendants in more than 300 private civil lawsuits.