The Trump administration can withhold millions of dollars in law enforcement grants to force states to cooperate with U.S. immigration enforcement, a federal appeals court in New York ruled Wednesday in a decision that conflicted with three other federal appeals courts.

The ruling by the 2nd U.S. Circuit Court of Appeals in Manhattan overturned a lower court's decision ordering the administration to release funding to New York City and seven states - New York, Connecticut, New Jersey, Washington, Massachusetts, Virginia and Rhode Island.

The states and city sued the U.S. government after the Justice Department announced in 2017 that it would withhold grant money from cities and states until they gave federal immigration authorities access to jails and provide advance notice when someone in the country illegally is about to be released.

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.

Court boost: Cities including New York can be stripped of law enforcement cash for refusing to co-operate with federal immigration authorities, federal appeals judges ruled

Blow: Andrew Cuomo, New York's governor, had tried to stop the DOJ from blocking law enforcement funding, along with six other states and New York City, all of which are in Democratic control

At the time, then-Attorney General 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 make clear that the U.S. attorney general can impose conditions on states and municipalities receiving money.

And it noted that the U.S. Supreme Court has repeatedly observed that the federal government maintains broad power over states when it comes to immigration policies.

In the past 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.

'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,' the 2nd Circuit three-judge panel said in a decision written by Judge Reena Raggi.

'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.

Deployment: The DOJ claims that punishing 'sanctuary cities' for refusing to cooperate with immigration authorities makes the U.S. safer

The Justice Department praised the decision, issuing a statement calling it a 'major victory for Americans' and saying it recognizes that the attorney general has authority to ensure that grant recipients are not thwarting federal law enforcement priorities.

The department added that the ruling's effect will be limited because other courts have ruled the other way, giving the plaintiffs in the New York case the opportunity to point to those as reasons to ignore the new conditions.

Cody Wofsy, a staff attorney with the American Civil Liberties Union, called the decision a 'real outlier,' saying he believed the 2nd Circuit was the nation's first court to side with the Trump administration on the issue.

'Over and over, courts have said the Department of Justice doesn't have authority under governing statutes to impose these conditions,' he said. 'These conditions are part of the administration´s attempts to bully, cajole and coerce state and local governments into participating in federal immigration enforcement activities.'

Under the Constitution's federalism principles and the 10th Amendment, Wofsy said, states and municipalities 'are entitled to decline to become part of the administration´s deportation force.'

The appeals rulings pertain to the issuance of the Edward Byrne Memorial Justice Assistance Grant Program.

Created in 2006, it is the vehicle through which Congress annually dispenses over $250 million in federal funding for state and local criminal justice efforts.

The Byrne Program was named for New York City Police Officer Edward Byrne, who at age 22 was shot to death while guarding the home of a Guyanese immigrant cooperating with authorities investigating drug trafficking.