NEW YORK (AP) — 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 decision 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.

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

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.

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.

Comment on this story on MassLive’s Facebook page