A federal judge made the order on Thursday, writing in a legal decision seen by Reuters that the money would be put in a state fund and used for projects in the area affected by the collapse.

It was not immediately clear how much each company owes.

Vale and BHP said in separate statements, they had not been informed by the judiciary about the ruling.

Samarco declined to comment.

The collapse of the tailings dam, which stores mining waste, caused a huge mudslide in the southeastern city of Mariana in November 2015.

It killed 19 people and severely polluted the Rio Doce, a river that runs into the Atlantic Ocean.

The ruling came on the day that marked five years since a separate dam collapse killed hundreds of people, not far from Mariana and also linked to Vale.

Families held a protest and a tribute for the victims of the Brumadinho disaster, demanding justice.

"It is difficult to explain in words the feeling that we have after five years. It seems that every day I wake up and it is as if they are present because I did not have a goodbye from them. That wasn't meant to happen."

"We, and other family members, are seeking justice. We are here for them, for each of the victims."

The collapse of the tailings dam at the Vale-owned mine unleashed a wave of mud, killing 270 people and damaging homes, forests and rivers.

Vale has reported it "remains committed to Brumadinho repairs".

It says it has reached deals with more than 15,400 people to pay damages.