Six states and New York City sued the federal government Wednesday, joining other cities and states who say the Trump admin is trying to unlawfully force "sanctuary" communities to engage in federal immigration enforcement if they want anti-crime funds.

Lawsuits were filed in Manhattan federal court on behalf of New York state and city, Connecticut, New Jersey, Washington, Massachusetts and Virginia.

The federal government in July 2017 imposed conditions requiring cities receiving public safety grants to notify federal agents when immigrants in the country illegally are about to be released from police detention.

Since then, federal courts in Illinois, Pennsylvania and California have struck down the conditions affecting so-called "sanctuary" communities.

Justice Department spokesman Devin O'Malley called two lawsuits filed Wednesday "a disservice to these states' law-abiding citizens."

New Sanctuary Coalition volunteer Alice Strum Sutter, center, holds a sign as she watches a news conference at the Holyrood Church on Aug. 17, 2017, in the Washington Heights neighborhood of Manhattan. Mary Altaffer / AP file

By choosing not to comply with a federal statute that promotes cooperation between local jurisdictions and federal immigration authorities, political leaders deliberately choose to protect criminal aliens in their custody and to make their communities less safe," he said.

The six states say they could lose a total of nearly $25 million in funds. In recent weeks, they were notified they must participate in the federal government's immigration policies to receive their money, officials said.

New York City is one of five local governments eligible to receive the largest awards, with $4 million headed its way, authorities said.

"Our message is clear: the Trump Administration's actions are illegal and morally bankrupt," New York City Mayor Bill de Blasio said in a release.

"We have proven, time and again, that welcoming immigrants has helped make this the safest big city in the country. Any attempt to jeopardize the trust between our local law enforcement and immigrant New Yorkers will fail," de Blasio added.

The lawsuits seek a judge's declaration that the policy change announced last year and enforced recently is unconstitutional.

Lawyers for the states wrote in court papers that the Justice Department was forcing states to accept unlawful conditions that diminish their ability to set their law enforcement priorities and protect their communities.

Zachary W. Carter, New York City's corporation counsel, said the federal government's efforts would cause immigrant communities to disengage from public service "and retreat into the shadows, to the detriment of their own safety and that of the public."

The Justice Department has announced it is distributing $200 million in funds to communities that share its commitment to "keeping criminal aliens off our streets and our law-abiding citizens safe," New York City said in its release.

In April, a federal appeals court in Chicago said President Donald Trump's administration exceeded its authority when it established new conditions for cities to qualify for grants. But it issued a partial stay of a lower court's order blocking the government until the full appeals court considers whether it was proper to block the federal government nationwide.

Besides Chicago, cities from California to Massachusetts have established policies to protect immigrants since Trump won the 2016 election.

"With the lawsuit filed today, New York and other states are sending a message loud and clear that we will not stand for intolerance or hate and we will not be bullied with disgraceful political tactics, let alone ones that are blatantly unconstitutional," New York Democratic Gov. Andrew Cuomo said in a statement.