In 2016, a rights tribunal ruled that the government had underfunded First Nations children’s services compared with those for non-indigenous children.
It ordered C$40,000 ($31,350; £23,340) payouts to each child forced to leave their homes to access the services.
Wednesday’s court ruling is expected to cost Ottawa billions of dollars.
Announcing the decision, Justice Paul Favel said the federal government had “not succeeded in establishing that the compensation decision is unreasonable”.
Mr Favel also said that the Canadian Human Rights Tribunal “reasonably exercised its discretion” under the Canadian Human Rights Act to “handle a complex case of discrimination to ensure that all issues were sufficiently dealt with”.
Prime Minister Justin Trudeau’s government says it is reviewing the latest ruling.
The government had filed its legal challenge, arguing that the tribunal was wrong to award C$40,000 payouts – the maximum allowed under the Canadian Human Rights Act.
Mr Trudeau had said his cabinet wanted to “make sure we’re getting compensation right”.
Cindy Blackstock from the First Nations Child and Family Caring Society said the ruling was “a complete rejection of all the government’s spurious arguments, and a complete win for kids.”