A federal judge in Chicago has blocked an order requiring cities to fully cooperate with immigration officials or risk losing some federal funding.
The ruling is a fresh blow to US President Donald Trump, who has promised to end illegal immigration and so-called "sanctuary cities".
The judge said it was likely Attorney General Jeff Sessions had overstepped his authority with the order.
The preliminary injunction applies to more than 400 cities nationwide.
In July, Mr Sessions announced that certain funding would only be awarded to jurisdictions allowing federal immigration officers into detention facilities and which gave 48 hours' notice before releasing inmates wanted by the federal authorities.
It was seen as a further attempt to punish cities and other areas that are part of the "sanctuary" movement aimed at shielding illegal immigrants from stepped-up deportation efforts.
What is a 'sanctuary city'?
- The term applies to cities in the US that have policies to limit the assistance given to federal immigration authorities
- Officials in those areas, including local law enforcement, are not allowed to enquire as to an individual's immigration status in the course of their duties
- It is not a legal term so the way it is implemented can vary, but the policies can be set in law or just part of local policing practices
- The idea got traction in the 1980s after Los Angeles told its police force to stop questioning people solely to determine their immigration status, in a bid to encourage immigrant communities to work with police
- More than 400 jurisdictions across the US, including New York, San Francisco, Boston, Chicago and Seattle, have enacted policies protecting undocumented immigrants
- Critics say these policies undermine federal law enforcement efforts and encourage illegal immigration
Chicago Mayor Rahm Emanuel's administration filed a lawsuit in August against the Sessions order arguing that it was unconstitutional.
Lawyers for the city also claimed that withholding funding creates a dangerous precedent in which the federal government could begin withholding money from jurisdictions that disagree with the president's priorities.
"The court finds that the city has established that it would suffer irreparable harm if a preliminary injunction is not entered," US District Judge Harry Leinenweber said in his 41-page ruling.
The Trump administration argues that the deportation crackdown is aimed at immigrants convicted of serious crimes and that public safety is jeopardised when immigration authorities are not informed of impending releases.