A federal judge has ruled that the White House must give migrants sent to an El Salvador prison a chance to challenge their removals.

Judge James Boasberg did not specifically outline the steps the Trump administration needs to take, but said one week would be given for the government to outline how it intends to comply.

He said that people who were sent to the prison under an 18th-century wartime law haven´t been able to formally contest the removals or allegations that they are members of the Venezuelan gang Tren de Aragua.

Boasberg ordered the administration to work toward giving them a way to file those challenges.

The judge wrote that 'significant evidence' has surfaced indicating that many of the migrants imprisoned in El Salvador are not connected to the gang 'and thus languish in a foreign prison on flimsy, even frivolous, accusations.'