SAN FRANCISCO — A federal judge ordered the Trump administration to suspend the deportation of about 1,400 Iraqis, saying the government is moving too quickly to return them to a country where they face a “grisly fate” including persecution and torture.

U.S. District Judge Mark Goldsmith in Detroit said in Monday’s order the Iraqis must be given a chance to challenge their deportations so that those facing “grave harm and possible death are not cast out of this country before having their day in court.”

The Iraqis targeted by immigration authorities, including a mix of Muslims and Christians from the Detroit area and elsewhere in the U.S., were previously deemed eligible for removal after they were convicted of crimes or had overstayed their visas.

The decision impacts the fate of Niberd Alzendi Abdalla, a Hampshire County man currently detained by Immigration and Customs Enforcement in Boston. Abdalla, held since June 8, came to the U.S. from Iraq at 15 and has lived here more than 40 years.

Buz Eisenberg, a coordinating attorney for the new ACLU Immigrant Protection Project of Western Massachusetts who has a 10-year background in defending Guantanamo Bay detainees, is representing Abdalla.

“This decision provides hope to people who have had their hope damaged in recent months. The court in Michigan is taking time to reflect on real lives and the destruction that the administration’s policy is wreaking on them,” Eisenberg said Tuesday. “By taking the time to think through the impact of these policies and not allow these people to be shipped off on the whim of Donald Trump the court is striking a blow for justice in an unjust arena.”

Because the immigrants’ cases remained dormant for years before the Trump administration abruptly moved for deportation after reaching a deal with the Iraqi government to take them back, their lawyers are now crying foul. The repatriation agreement with Iraq was negotiated as a condition of dropping that country from the president’s executive order temporarily banning travelers from a group of mostly Muslim nations.

Goldsmith said he was obliged to intervene because the federal government was on the cusp of violating fundamental rights of liberty protected by the U.S. Constitution. The judge said that by moving the Iraqis to detention centers across the country, Immigration and Customs Enforcement has made it difficult for them to get legal representation.

He also said that many of those targeted belong to religious minorities who face a serious threat of persecution if they are repatriated, both from militias associated with the Iraqi government and the Islamic State.

‘The record is clear that all petitioners will be targeted for torture or death based solely on their association with America,” Goldsmith wrote.

The court order bars individual Iraqis from being deported until they have a chance to pursue their claims before administrative immigration judges.

Staff writer Amanda Drane contributed to this report.