WASHINGTON (Reuters) - A U.S. judge ordered the government on Tuesday to either release Iraqi immigrants it arrested last year or grant them bond hearings, in the latest judicial curb on the Trump administration’s efforts to tighten U.S. immigration.

Slideshow ( 2 images )

Last year the federal government detained hundreds of Iraqi immigrants who had been ordered deported years ago due to criminal convictions. Iraq until recently had refused to take them back, but struck a deal with the United States in March to repatriate its citizens, sparking the immigration sweeps.

The Iraqis and civil rights groups representing them sued the federal government. U.S. District Judge Mark Goldsmith, in Detroit, had previously halted the deportation of the Iraqis, many of whom are Christian, who argued they would face persecution if they were sent back to Iraq.

In his ruling on Tuesday, Goldsmith said that any of the Iraqis held for six months or longer must either be released or granted a bond hearing before an immigration judge within 30 days.

“Our legal tradition rejects warehousing human beings while their legal rights are being determined,” wrote Goldsmith.

The Trump administration has tried to deport the Iraqis as part of its push to increase immigration enforcement and make countries, which have resisted in the past, take back nationals ordered deported from the United States.

Since June, immigration enforcement officers have detained approximately 300 Iraqi nationals with final deportation orders, according to information provided to the court by the Iraqis’ lawyers. There are approximately 1,400 Iraqis in the United States with final deportation orders.

The U.S. government said in March that Iraq had agreed to repatriate Iraqi nationals ordered deported from the United States.

But Goldsmith noted in his order that the United States has “no written agreement” with Iraq regarding its cooperation, and that it is therefore unclear whether Iraq had agreed to take back all its nationals, and if so, under what conditions.

Goldsmith said his ruling would apply to Iraqi detainees in similar circumstances nationwide, even if they are not involved in the litigation.

“(Goldsmith) just really reaffirmed the principle that indefinite detention in this country is not acceptable,” said Kary Moss, executive director of the American Civil Liberties Union of Michigan, which is representing the Iraqis.

The Department of Justice, which is arguing on behalf of the government, did not immediately respond to a request for comment.