BP have reached an agreement with states and the U.S. in the 2010 Gulf of Mexico oil spill case, five years after the accident.

BP has agreed to pay $18.7 billion over 18 years to settle all federal and state claims arising from the Deepwater Horizon oil spill. The states sued BP under a federal law, known as the Oil Pollution Act, that holds polluters liable for municipal losses caused by oil spills

“Five years ago we committed to restore the Gulf economy and environment and we have worked ever since to deliver on that promise,” said BP chairman Carl-Henric Svanberg.

“We have made significant progress, and with this agreement we provide a path to closure for BP and the Gulf. It resolves the company’s largest remaining legal exposures, provides clarity on costs and creates certainty of payment for all parties involved,” he added.

BP shares rose 2.8% in early afternoon trading.