RIO DE JANEIRO, Jan 29 (Reuters) - Miners Vale , BHP and their joint venture, Samarco, should strike a deal to compensate for a deadly dam disaster in 2015 or risk paying a lot more in court, the Minas Gerais state prosecutor general told Reuters.

Last week a federal judge ruled that the firms must pay up to 47.6 billion reais ($9.67 billion) in damages, in a decision still subject to appeal.

In an interview on Friday, Minas Gerais state Prosecutor General Jarbas Soares Junior told Reuters that the federal ruling only accounts for collective damages, with the firms still on the hook for damages caused to states, to the environment and to other parties involved.

"The total will be very high," he said, adding that the firms should strike a deal when talks resume in February, to avoid more costly litigation.

Soares Junior is one of the many officials that would have to sign off on a deal that could settle lawsuits on state and federal levels involving the disaster.

The 2015 dam collapse in the southeastern city of Mariana caused a giant mudslide that killed 19 people and severely polluted the Rio Doce river, compromising the waterway to its outlet in the Atlantic Ocean.

In separate statements Vale, BHP and Samarco said they were committed to repairing the damage caused by dam collapse, while declining to comment on the court ruling, because they have not yet been notified by the judiciary of it.

Vale added that the Renova foundation, which the companies have been using to pay for some of the repairs, had paid until last December 34.7 billion reais in socioeconomic and environmental compensation.

($1 = 4.9437 reais) (Reporting by Marta Nogueira, writing by Fabio Teixeira; editing by Sandra Maler)