Several Massachusetts district attorneys filed a federal lawsuit Monday demanding a judge order ICE to stop enforcing the law at state courthouses, saying too many people are refusing to be witnesses or show up for cases because they fear being deported.

Prosecutors in Middlesex and Suffolk counties said there’s long been a “common law” privilege protecting anyone doing official business at a courthouse, and they said arresting people — either witnesses, bystanders or criminals — breaks that.

“Entire communities now view the Massachusetts courts as places where they cannot go, for any reason, greatly impeding access to justice and undermining the administration of justice in these communities,” the prosecutors said in their complaint.

The lawsuit has produced a strange alliance. The prosecutors were joined in suing by the Committee for Public Counsel Services, which is a public defenders service, and Lawyers for Civil Rights.

The lawsuit comes less than a week after federal prosecutors won an indictment against a state judge charged with helping a twice-deported immigrant living illegally in the U.S. escape her courtroom to avoid arrest by U.S. Immigration and Customs Enforcement.

That case made national headlines.

But Monday’s lawsuit says the bigger danger is on the other side of the ledger, where they said victims aren’t coming forward and cases aren’t being made on a range of matters, from sexual assault to housing and employment violations.

“A clear consensus has emerged in Massachusetts, and across the nation, among all stakeholders in the legal community that ICE’s civil-courthouse-arrest policy has resulted in a noticeable chill on court access, and as a result, on access to justice,” the lawsuit charges.

The prosecutors, in their lawsuit, blamed “the last two years” of activities.

But courthouses have been fair game for enforcement for years, including under President Obama.

ICE says it doesn’t formally track how many of its arrests are made in courthouses, but the agency considers courthouses to be good places to make arrests because they are secure locations.

“Individuals entering courthouses are typically screened by law enforcement personnel to search for weapons and other contraband. Accordingly, civil immigration enforcement actions taken inside courthouses can reduce safety risks to the public, targeted alien(s), and ICE officers and agents,” a spokesman said in an emailed statement.

ICE acknowledges on its website that the number of courthouse arrests is rising. The agency blames sanctuary cities, who in the past would have allowed their officers to turn over migrants, but who now are restricted from cooperation, forcing ICE officers to make individual arrests themselves.

“In such instances, ICE officers and agents make every effort to take the person into custody in a secure area, out of public view, but this is not always possible,” the agency says. “Further, when these arrests do occur, ICE makes every effort to ensure that the arrest occurs after the matter for which the alien was appearing in court has concluded.”

ICE does not conduct arrests at schools, hospitals, churches or public rallies, but it has resisted attempts to expand sanctuary zones beyond those locations.

The sensitive locations policy was codified under the Obama administration, and the Trump administration says it has made no changes.

Massachusetts prosecutors’ lawsuit is novel, but they’re not the first to try to push ICE out of courthouses.

New York state courthouses announced a new policy earlier in April insisting that any ICE officer who wants to make an arrest must obtain a warrant from a judge.

The state Office of Court Administration said since the courthouses are open public buildings, it couldn’t ban ICE from entering. But officers will be asked to show a warrant should they want to take someone into custody.

ICE issues administrative warrants, but since immigration is not a criminal matter, the agency says there is no process to get a judicial warrant.

Ivan Espinoza-Madrigal, executive director of Lawyers for Civil Rights, said he hopes other jurisdictions follow the lead of the Massachusetts coalition and challenge ICE in their own districts.

“This lawsuit provides a powerful blueprint for advocates across the country who want to protect access to the courts and to judicial redress,” he said.