Washington (CNN) A federal appeals court struck another blow Thursday to the Trump administration's efforts to pressure sanctuary cities, upholding a court order preventing the Justice Department from imposing conditions on grants to cities.

The three-judge panel from the 7th US Circuit Court of Appeals upheld a lower court's decision blocking the Justice Department from adding new conditions on policing grants that had required some cooperation with federal immigration enforcement.

It comes as President Donald Trump has been targeting his fury on Twitter at sanctuary cities, which administration officials accuse of jeopardizing public safety.

The judges sided with the city of Chicago in the case, which had challenged Attorney General Jeff Sessions' July effort to condition the Edward Byrne Memorial Justice Assistance Grant Program on two new requirements: allowing federal immigration authorities access to local detention facilities and providing the Department of Homeland Security with at least 48 hours' notice before local officials release an undocumented immigrant wanted by federal authorities.

The administration has been aggressive in asking cities to comply with those requests, but a number of cities and police chiefs around the country argue that cooperating in that way could jeopardize the trust police need to have with local communities, and in some cases could place departments in legal gray areas.

Like the district judge, the appellate judges found that Chicago was likely to succeed in its case that such conditions would be a violation of the Constitution and law, as Congress did not authorize those conditions when it created the grants.

The judge who wrote the opinion called the attorney general's move a "usurpation of power."

"The attorney general in this case used the sword of federal funding to conscript state and local authorities to aid in federal civil immigration enforcement," wrote Judge Ilana Rovner. "In fact, Congress repeatedly refused to approve of measures that would tie funding to state and local immigration policies. Nor, as we will discuss, did Congress authorize the Attorney General to impose such conditions. It falls to us, the judiciary, as the remaining branch of the government, to act as a check on such usurpation of power."

The justice assistance grant program gives local jurisdictions millions of dollars yearly to support law enforcement.

One of the three judges, Daniel A. Manion, agreed with the decision as it related to Chicago but said the ruling should not apply nationwide.

In a statement, Justice Department spokesman Devin O'Malley said the department still believes it has the authority to impose the conditions and criticized the judiciary's use of nationwide prohibitions to block the administration's agenda.

"Many in the legal community have expressed concern that the use of nationwide injunctions is inconsistent with the separation of powers, and that their increased use creates a dangerous precedent," O'Malley said. "We will continue to fight to carry out the department's commitment to the rule of law, protecting public safety, and keeping criminal aliens off the streets to further perpetrate crimes."

The term sanctuary city loosely refers to jurisdictions that in some way do not cooperate with federal immigration enforcement. The stated reasons vary, from protecting undocumented immigrants to preserving law enforcement's ability to gain the trust and cooperation of communities. Some jurisdictions have also been barred by the courts from complying with certain federal requests.