BP has reached an $18.7 billion settlement with the federal government and five states, effectively ending litigation stemming from the 2010 Deepwater Horizon rig explosion and subsequent oil spill.