Mining company Samarco and its owners, BHP Billiton and Vale SA , reached a deal with the Brazilian government on Wednesday to pay an estimated 20 billion reais ($5.1 billion) in damages over 15 years for a deadly dam spill in November.

Considered Brazil’s worst environmental disaster, the burst tailings dam in the state of Minas Gerais killed 19 people, left hundreds homeless and polluted a major river.

Of the total, Samarco will pay 4.4 billion reais through 2018 into a fund to cover the cleanup of the spill from the tailings dam. From 2019 to 2021, payments will be between 800 million reais and 1.6 billion reais.

“We want to build new life on the rubble of an unprecedented tragedy,” President Dilma Rousseff said at the signing ceremony in Brasilia.

Beyond 2021, the amount will be decided depending on how much work remains to be done. The government estimates the total cost of the lengthy environmental plan, including replanting and dredging, will reach about 20 billion reais.

The 20 billion reais figure was, however, noticeably absent from statements sent by Samarco, BHP and Vale. The obligations outlined by the companies instead came to about 12 billion reais over the first six years. The difference, the government explained, was due to estimates of amounts that can be only decided in the future.

“This is not about a dollar amount, this about a program to remediate, to restore and where we can’t restore to compensate and also to leave some positive legacies behind,” Dean Dalla Valle, BHP’s Chief Commercial Officer, told Reuters at the ceremony.

“Besides straight remediation, we are talking about actions like sewage, landfill, reforestation, water treatment,” he said.

In the event Samarco is unable to pay its obligations, Vale and BHP would be responsible for covering the costs, the joint venture partners said in separate statements.

Samarco interim Chief Executive Officer Roberto Carvalho told Reuters the company had enough cash to cover its obligations for this year, but would need its mine to restart in order to pay in 2017.

Vale said the accord does not cover private civil suits, other public civil suits or criminal investigations.

Investors drove shares in Vale up 8 percent and BHP Billiton up 6 percent, partly as the payments agreed were less than earlier speculated, but also on a rise in iron ore prices. Some highlighted it remained unclear what the final outlay would be.

“It’s a little bit better than perhaps the market was bracing for, but it’s still a very material and somewhat open-ended issue,” said Brenton Saunders, a portfolio manager at BT Investment Management.

Dalla Valle said Samarco could be in a position to restart its mine in the final quarter of the year. The company has already taken the first steps to get its licenses in place to restart.

“We will only start when it is absolutely safe, we will need to learn from the investigation. The way it will start won’t involve the current tailings dams,” Dalla Valle said.