BP has reached a comprehensive $18.7 billion settlement with the US government and five states, a landmark deal that effectively ends years of litigation over environmental damage and human casualties caused by the 2010 Gulf of Mexico spill.
The US Justice Department said it could be the largest settlement with a single entity in American history and the total value would top $20 billion.
The April 2010 rig explosion and spill killed 11 workers and spewed oil for nearly three months on to the shorelines of several states.
BP said the agreement covered claims from the states of Alabama, Florida, Louisiana, Mississippi and Texas and 400 local government entities.
BP's London-listed shares extended gains to as much as 5.3% in mid-afternoon trade as the extent of the company's liabilities became clear for investors.
The shares rose despite the company increasing its cumulative pretax charge for the disaster by about $10 billion to $53.8 billion.
"This is a realistic outcome which provides clarity and certainty for all parties," BP's chief executive Bob Dudley said in a statement.
"For BP, this agreement will resolve the largest liabilities remaining from the tragic accident," he added.
The size of the settlement was slightly more than the $17.6 billion that investors had feared BP would be fined under the Clean Water Act for gross negligence.
The maximum possible Clean Water Act fine was later trimmed to $13.7 billion after US District Court Judge Carl Barbier found 3.19 million barrels spilled, less than the US government claimed.
Barbier was expected to rule on that issue later this year, but even after that, BP would have still faced years of lawsuits to address claims by states and by the federal government under a natural resources damage assessment.
Today's settlement closes off the remaining liabilities and will bring over $6.8 billion to states.
The head of the US Justice Department, Attorney General Loretta Lynch, hailed the record settlement.
"If approved by the court, this settlement would be the largest settlement with a single entity in American history; it would help repair the damage done to the Gulf economy, fisheries, wetlands and wildlife; and it would bring lasting benefits to the Gulf region for generations to come," Ms Lynch said in a statement.