A U.S. District Judge in Detroit snubbed the Trump administration’s crackdown on immigrants on Tuesday, ordering the federal government to either release or grant bond hearings to Iraqi immigrants waiting to be deported due to criminal records.

U.S. District Judge Mark Goldsmith said in the ruling that the Iraqis held in custody for six months or longer must either be granted a bond hearing or be released within 30 days, Reuters reported.

“Our legal tradition rejects warehousing human beings while their legal rights are being determined,” wrote the judge in the ruling.

Roughly 1,400 Iraqi immigrants, including hundreds already in custody, are facing deportations back to their native country due to criminal convictions. Until recently Iraq refused to take them back, but an apparent deal between the Iraqi and U.S. governments in March allowed the government to proceed with the crackdown.

The move against Iraqi immigrants with criminal convictions was part of a larger move by the Trump administration to enforce existing immigration laws and ensure other countries - which previously ignored U.S. calls to take their citizens back – comply with the orders.

But last year, Goldsmith halted the deportations of the Iraqis, claiming they, many of whom are Christians, would be subjected to dangers in the country over their religion.

“Each petitioner faces the risk of torture or death on the basis of residence in America and publicized criminal records. Many will also face persecution as a result of a particular religious affiliation,” the judge said.

He also said that the U.S. government does not have a “written agreement” with Iraq regarding the cooperation and it remains unclear if the country wishes to take back its nationals, according to Reuters.

The Associated Press contributed to this report.