NEW YORK (Reuters) - New York and five other states filed a lawsuit on Wednesday seeking to block the Trump administration from making cooperation with federal immigration authorities a condition for receiving millions of dollars in federal funding for law enforcement.

The lawsuit, brought by New York, Connecticut, Massachusetts, New Jersey, Virginia and Washington, claimed that the U.S. Department of Justice had no legal authority to impose the condition.

New York City filed a similar lawsuit on Wednesday. Both lawsuits were filed in Manhattan federal court.

“Local law enforcement has the right to decide how to meet their local public safety needs, and the Trump administration simply does not have the right to require state and local police to act as federal immigration agents,” New York Attorney General Barbara Underwood said in a press statement.

Wednesday’s lawsuits concern the Edward Byrne Memorial Justice Assistance Grants, which provide federal funds for state and local law enforcement. They are the latest in a number of legal battles over President Donald Trump’s immigration policies, which have included separating children and parents crossing the Mexican border illegally.

“Today’s lawsuit is a disservice to these states’ law-abiding citizens, but the Department of Justice will continue to fight for the rule of law, to protect public safety, and to keep criminal aliens off the streets,” Justice Department spokesman Devin O’Malley said in a statement.

The administration said 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 they were given an Aug. 10 deadline to decide whether to accept funds with conditions.

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

A federal appeals court in Chicago in April upheld a lower court order blocking funding conditions for that city. The appeals court is expected to hear arguments in September on whether the order should or can apply nationwide.

Philadelphia won a separate challenge to the policy in June, and San Francisco, Illinois and the state of California have pending court challenges.