President Donald Trump's immigration agenda was dealt another blow by federal courts Friday, when a federal judge largely blocked the Justice Department's efforts to punish sanctuary cities for a second time this year.

US District Court Judge Harry D. Leinenweber agreed with the city of Chicago that the administration's new requirements for receiving a key law enforcement grant that hinged on immigration enforcement could cause "irreparable harm," adding that the city had shown a "likelihood of success" in its case that Attorney General Jeff Sessions exceeded his authority in requiring local jurisdictions to comply with the new standards.

Leinenweber blocked the Justice Department from enforcing the new measures, which it introduced earlier this summer, meaning cities applying for the funds this year will not have to comply.

"The harm to the city's relationship with the immigrant community, if it should accede to the conditions, is irreparable," Leinenweber wrote. "Once such trust is lost, it cannot be repaired through an award of money damages."

Friday's decision marked the second time this year a federal judge has blocked the Trump administration's efforts to force sanctuary cities to cooperate on immigration enforcement. A judge in San Francisco restricted a January executive order from Trump that threatened to block all federal funds to sanctuary cities -- a catchall term generally used to describe jurisdictions that have some policy of noncooperation with federal immigration enforcement.

The administration has made such jurisdictions a key focus of its immigration agenda -- arguing that such policies are a public safety threat.

"By protecting criminals from immigration enforcement, cities and states with 'so-called' sanctuary policies make their communities less safe and undermine the rule of law," Justice Department spokesperson Devin O'Malley said. "The Department of Justice will continue to fully enforce existing law and to defend lawful and reasonable grant conditions that seek to protect communities and law enforcement."

In a tweet, Chicago Mayor Rahm Emanuel heralded the judge's ruling as a victory.

"This is not just a victory for Chicago. This is a win for cities across the US that supported our lawsuit vs Trump DOJ defending our values," Emanuel tweeted.

At issue in the case was a new salvo the administration opened against sanctuary cities in July, when Sessions announced that going forward, funds under the Edward Byrne Memorial Justice Assistance Grant Program, or Byrne JAG, would be conditioned upon two new requirements: allowing federal immigration authorities access to local detention facilities and providing the Department of Homeland Security at least 48 hours' advance notice before local officials release an undocumented immigrant wanted by federal authorities.

Those are some of the most controversial requests by the federal government regarding local law enforcement. A number of cities and police chiefs around the country argue that cooperating with such requests could jeopardize the trust police need to have with local communities, and in some cases could place departments in legal gray areas. The Trump administration, on the other hand, has accused sanctuary cities of putting politics over public safety.

Leinenweber temporarily blocked both requirements on a nationwide basis Friday, explaining that the federal government does not have the authority to place new immigration-related conditions on the grants, as Congress did not grant that authority in setting up the program.

Emanuel sued Sessions over the new requirements in August, saying they would "federalize local jails and police stations, mandate warrantless detentions in order to investigate for federal civil infractions, sow fear in local immigrant communities, and ultimately make the people of Chicago less safe."

The conditions in July came after a federal judge in April restricted a January executive order that sought to block federal funds going to sanctuary cities to the JAG grants exclusively and existing requirements on them. After the administration failed in its attempt to get that injunction lifted, Sessions announced the new measures.

The Justice Department did get one win, however. Leinenweber did side with the Trump administration on preserving an existing requirement for the grants -- certifying compliance with a federal law that mandates local jurisdictions communicate immigration status information to the federal government -- which was put in place originally by the Obama administration.

Virtually all jurisdictions in the US say they are already in compliance with that measure.

The-CNN-Wire

™ & © 2017 Cable News Network, Inc., a Time Warner Company. All rights reserved.