(Reuters) - A federal judge on Thursday halted the deportation of all Iraqi nationals detained during recent immigration sweeps across the United States until at least July 24, extending a stay that was originally set to expire on Monday.

U.S. District Judge Mark Goldsmith in Detroit said there was "good cause" to extend the stay, which was sought by the American Civil Liberties Union. The ACLU says those arrested in immigration enforcement operations last month mostly in Michigan and Tennessee face persecution, torture or death if they are deported to Iraq.

Many of 199 Iraqis detained - largely in the Detroit area and in Nashville - were Chaldean Catholics and Iraqi Kurds. Both groups say they could be targeted for attacks in Iraq because they are visible minorities.

Those arrested by immigration authorities had outstanding deportation orders and many had been convicted of serious crimes, ranging from homicide to weapons and drug charges, according to the U.S. government.

Some of those affected came to the United States as children and committed their crimes decades ago, but they had been allowed to stay because Iraq previously declined to issue them travel documents. The U.S. government considered Iraq one of the recalcitrant countries that refused to accept back people ordered deported by U.S. immigration courts.

That changed after Iraq agreed in March to start accepting U.S. deportees as part of a deal that removed the country from President Donald Trump's revised temporary travel ban.

Goldsmith ruled earlier that the stay should be applied to allow detainees time to find legal representation to appeal against their deportation orders.

(Reporting by Mica Rosenberg in New York and Steve Friess in Detroit; Editing by Cynthia Osterman)