A federal appeals court on Wednesday ruled that the Trump administration can withhold millions of dollars in law enforcement grants as a way to push states to cooperate with U.S. immigration enforcement agencies.

The ruling, from the U.S. 2nd Circuit Court of Appeals in Manhattan, overturns another court’s decision that had ordered the federal government to release funds to New York City and seven other states — New York, Connecticut, New Jersey, Washington, Massachusetts, Virginia and Rhode Island.

“While mindful of the respect owed to our sister circuits, we cannot agree that the federal government must be enjoined from imposing the challenged conditions on the federal grants here at issue,” Judge Reena Raggi, who serves on the 2nd Circuit’s three-judge panel, wrote in a decision.

“These conditions help the federal government enforce national immigration laws and policies supported by successive Democratic and Republican administrations. But more to the authorization point, they ensure that applicants satisfy particular statutory grant requirements imposed by Congress and subject to Attorney General oversight,” the appeals court said in overturning the lower court’s ruling.

TRENDING: Black Lives Matter Activist Wearing 'Justice for Breonna Taylor' Shirt Walked into a Louisville Bar and Murdered Three People

The states and New York City had sued the federal government after the Justice Department announced in 2017 that it would not release grant money until they gave federal immigration authorities “access to jails and provide advance notice when someone in the country illegally is about to be released,” the Associated Press reported.

Before the change, cities and states seeking grant money were required only to show they were not preventing local law enforcement from communicating with federal authorities about the immigration status of people who were detained. At the time, then-Atty. Gen. Jeff Sessions said: “So-called ‘sanctuary’ policies make all of us less safe because they intentionally undermine our laws and protect illegal aliens who have committed crimes.” In 2018, the Justice Department imposed additional conditions on the grant money, though challenges to those have not yet reached the appeals court in New York. The 2nd Circuit said the plain language of relevant laws makes clear that the U.S. attorney general can impose conditions on states and municipalities receiving money. And it noted that the Supreme Court has repeatedly observed that the federal government maintains broad power over states when it comes to immigration policies. In the last two years, federal appeals courts in Chicago, Philadelphia and San Francisco have ruled against the federal government by upholding lower-court injunctions placed on the enforcement of some or all of the challenged conditions.

The Justice Department praised the appeals court ruling, calling it a “major victory for Americans” and noting that it allows the the attorney general to have authority to ensure that grant recipients follow the law.