NEW YORK (Reuters) - The Trump administration cannot compel states and cities to cooperate with federal immigration authorities as a condition for receiving millions of dollars in federal law enforcement funds, a New York federal judge ruled on Friday.

FILE PHOTO: Activists and Deferred Action for Childhood Arrivals (DACA) recipients protest against the Trump administration's policies on immigrants and immigration, during a demonstration in Manhattan, New York, U.S., March 1, 2018. REUTERS/Amr Alfiky/File Photo

The ruling by U.S. District Judge Edgardo Ramos in Manhattan is a victory for New York City and the states of New York, Connecticut, Massachusetts, New Jersey, Virginia and Washington, which had sued the administration over the conditions in July. Ramos is at least the fourth federal judge to rule against U.S. President Donald Trump’s administration on the issue.

Ramos ordered the administration to award the funds without conditions.

“Today’s decision is a major win for New Yorkers’ public safety,” New York Attorney General Barbara Underwood said in a statement.

The U.S. Department of Justice could not immediately be reached for comment.

The lawsuits concern the Edward Byrne Memorial Justice Assistance Grants, which provide federal funds for state and local law enforcement.

The Trump administration announced last year that to receive funding, state and local governments must give federal immigration authorities access to their jails and advance notice of immigrants’ release from custody.

The six states, which received grants totaling $25 million in the last fiscal year, said in their lawsuit they were given an Aug. 10 deadline to decide whether to accept funds with conditions.

New York City, in a separate lawsuit, said it was entitled to $4 million but that the Justice Department has refused to release it.

Federal judges in Pennsylvania, California and Illinois have already ruled against the policy. The 7th U.S. Circuit Court of Appeals has upheld the Illinois ruling, finding that Congress, and not the administration, has the authority to decide how the funds are spent.

Ramos said on Friday that he agreed with that decision, and that legal limits on executive authority were “a check on tyranny and the concentration of power.”