A federal judge in Chicago late Friday issued a nationwide injunction against the Trump administration's effort to crack down on sanctuary cities.

District Judge Harry Leinenweber sided with Chicago officials who argued that penalizing cities for protecting undocumented immigrants was unlawful and unconstitutional.

He made his ruling national in scope because there is "no reason to think that the legal issues present in this case are restricted to Chicago or that the statutory authority given to the attorney general would differ in another jurisdiction."

The decision follows others in California and Texas that also came down on the side of immigrants and against the Justice Department's effort. Those rulings are being appealed, as the latest one is almost sure to be.

Last month, a federal judge barred Texas from enforcing most of a state law requiring cities to comply with the federal efforts. In April, a federal judge limited the administration's ability to withhold federal grants to local communities that refused to cooperate with immigration enforcement.

The outcome of the cases could establish a clear line between federal and state responsibilities on immigration enforcement, a gray area that has been the subject of an intense fight since Arizona passed a law cracking down on undocumented immigrants in 2010.

"Sanctuary cities" is a general term that describes more than 300 local governments that have limited their cooperation with federal immigration officials. Trump attacked them repeatedly during his presidential campaign, arguing that local leaders are allowing dangerous undocumented immigrants to roam free in their communities.

The local communities have argued that immigration enforcement is a federal responsibility and that the U.S. Constitution prohibits Washington from forcing them to assist. Even so, many states led by Republicans are following Trump's lead.

The legal battle between federal and local governments could take years to resolve, but court rulings so far have made some aspects clear.

They have allowed police officers to ask suspects they stop about their immigration status and share that information with federal immigration agents. The judge in Texas allowed that portion of the law to go into effect, just as the Supreme Court upheld a portion of Arizona's law that required local police to ask suspects about their immigration status if the officer had a "reasonable suspicion" they entered the country illegally.

But courts have ruled against broader efforts to punish sanctuary cities. In 2012, the Supreme Court struck down portions of Arizona's law targeting undocumented immigrants, and another section that allowed arrests of undocumented immigrants without a warrant.