(The Center Square) — New York City Mayor Eric Adams has joined a legal challenge against the Trump administration's policy of arresting undocumented immigrants at city courthouses.

The city's Legal Department has filed a legal brief in support of a lawsuit by the American Civil Liberties Union and other groups that asks a federal judge to block Immigration and Customs Enforcement officials from detaining immigrants who show up for scheduled hearings at a Lower Manhattan federal immigration building.

Adams, a Democrat who has been criticized for backing Trump administration immigration policies, called the arrests "illegal" and said they have driven many "law-abiding" immigrants to avoid courts, the police and other basic city services for fear of detention.

"From my first days as a rookie cop to my current role as mayor of New York City, my job is, and has always been, to keep law-abiding New Yorkers safe," Adams said in a statement. "We should allow New Yorkers to feel secure to attend legal proceedings in their pursuit to obtain legal status."

Immigration enforcement actions in courthouses have been a flashpoint in pushback by Democrats and civil liberty groups to Trump's administration's immigration enforcement. To enter America from another country, if not a U.S. citizen, a visa or some other travel authorization is required to be presented at a port of entry.

Advocates, court officials and even some judges have been accused of resisting attempts by ICE to apprehend suspects who show up for court hearings.

New York City Comptroller Brad Lander, a Democrat who was then seeking the Democratic nomination to run for mayor, was arrested in June for allegedly assaulting a U.S. Immigration and Customs Enforcement agent who was attempting to take an undocumented immigrant in a New York City courthouse into custody.

He was let go when Democratic New York Gov. Kathy Hochul showed up at the ICE detention facility to demand his release.

The Justice Department sued New York state in February over a state law that limits state cooperation with federal immigration authorities and again in June over the Protect Our Courts Act, which the DOJ said "shields dangerous aliens from being lawfully detained" and violates the Constitution by obstructing federal immigration operations. Those cases are still pending.

In another lawsuit, the DOJ took New York City to federal court in July over its "sanctuary" policies that restrict cooperation with federal immigration crackdowns, accusing the city of shielding wanted criminals from deportation.