A federal judge has blocked an order issued by the Trump administration that would have kept thousands of migrants detained for an indefinite period while they waited for a resolution to requests for asylum in the United States.

The order issued by attorney general William Barr had represented the latest step by the administration to discourage migrants from seeking asylum, but a federal judge on Tuesday ruled that the measure could not be enforced.

Judge Marsha Pechman of the US district court in Washington state, said in her court ruling that the order, which would have seen a significant number of migrants seeking asylum denied a bail hearing, was unconstitutional.

The judge had issued a preliminary injunction earlier this year that required migrants seeking asylum, who are given a hearing in their proceedings, to be released within seven days after that hearing had been granted.

Mr Barr’s order, issued in April, had been the latest step by the Trump administration to prevent the release of migrants into the country, and attempt to deter asylum seekers from crossing the border altogether.

Late-night line-up at US immigration Show all 2 1 /2 Late-night line-up at US immigration Late-night line-up at US immigration immigration.jpg Getty Late-night line-up at US immigration immigrationtimes.jpg

The Trump administration in recent months has raised fees for migrants applying for asylum seekers and slowed processing at legitimate ports of entry as it fumbles to find a policy that could reduce immigration on a record scale.

For over a decade, migrants who have a credible fear of persecution in their home countries have been allowed to request hearings to be released on bail rather than be forced to wait in custody while waiting for their cases to be heard.

The order from Mr Barr, would have denied that right to a hearing to migrants who had illegally crossed the border into the country, even after he accepted it would aggravate conditions at overcrowded detention facilities.

Ms Pechman, in her ruling, also took issue with an aspect of Mr Barr’s measure that would have left open the possibility that migrants could be re-detained by ICE immigration officers after they had been released on bail.

The office of the White House press secretary condemned the decision in a statement on Wednesday morning, saying it incentivised smugglers and traffickers. “The district court’s injunction is at war with the rule of law,” it said.

Ms Pechman’s ruling comes amid a widespread shortage of immigration judges that has caused unprecedented delays in processing asylum cases. At the end of April, records showed the backlog stood at nearly a million cases.

Top officials involved in setting immigration policy have insisted a hard-line approach is necessary to stem the tide of migrants from entering the US, but many of the measures – some blocked by court orders – have largely failed.

“Hearing dates were being scheduled as far out as August 2023 in New York City, October 2022 in Los Angeles, and April 2022 in San Francisco,” the Transactional Records Access Clearinghouse (TRAC) reported.

Michael Tan, a migrant rights lawyer, said in a statement: “The court forcefully rejected the Trump administration’s bid to arbitrarily jail asylum-seekers without a hearing.”