Suffolk District Attorney Rachael Rollins said “it would be my honor” to be arrested by the feds over her opposition to ICE as she and Middlesex DA Marian Ryan filed a civil lawsuit Monday aimed at keeping Immigration and Customs Enforcement agents out of state courthouses.

Taking a defiant stand against U.S. Attorney Andrew Lelling, who last week indicted a judge for helping an illegal immigrant defendant evade ICE, Rollins said: “I am in no fear of arrest. And, very candidly, if I am, it would be my honor.”

Rollins has told her prosecutors to alert her to the presence of ICE agents in courthouses, and to tailor charges to avoid impacting a defendant’s immigration status.

In her latest move — catching other Massachusetts DAs by surprise — Rollins, Ryan and several advocacy groups sued ICE in U.S. District Court on Monday, claiming increased ICE activity at state courthouses has a “chilling effect” on illegal immigrants’ interaction with the justice system. The plaintiffs said that’s keeping illegal-immigrant victims, witnesses and defendants away from courthouses, making it tougher to prosecute cases. The suit claims the ICE actions violate “common law privilege” against civil arrests in courthouses.

“That is an assault on our justice system,” Ryan said Monday. “Not one person in our commonwealth is safer because of that practice.”

The DAs said they didn’t have any estimate of how many cases they believe might be affected.

ICE’s Boston field office declined comment, referring to a DOJ statement about courthouse arrests: “Now that some law enforcement agencies no longer honor ICE detainers or limit ICE’s access to their detention facilities, these aliens, many of whom have serious criminal histories, are released to the street, threatening public safety. Because courthouse visitors are typically screened upon entry to search for weapons and other contraband, the safety risks for the arresting officers, the arrestee, and members of the community are substantially diminished.”

The DAs’ lawsuit comes just days after a Newton judge and a court officer were indicted on federal charges of conspiring to help an illegal immigrant escape out the basement door of Newton District Court last spring. Lelling’s office declined to comment on the lawsuit and on Rollins’ statements. While welcoming the notion of indictment, Rollins also touted her cooperation with Lelling’s office in the Jassy Correia slaying case.

Cape & Islands DA Michael O’Keefe, meanwhile, slammed the suit as his fellow DAs simply playing politics.

“I really do see this as a pretext for resisting things politically that they don’t like,” O’Keefe told the Herald.

Plymouth DA Timothy Cruz, who is president of the Massachusetts District Attorneys Association, told the Herald that the lawsuit came as a surprise, and that Rollins and Ryan didn’t mention it at the DA organization’s meeting last Wednesday.

“I think that’s unfortunate,” Cruz said. He added, referring to Rollins and Ryan’s claim that illegal immigrants are avoiding the courts, “Show me the numbers. That’s what I’m looking to see — not just a handful of anecdotes.”

Worcester DA Joseph Early, Norfolk DA Michael Morrissey and Essex DA Jonathan Blodgett also said they first heard of the suit Monday — even though the suit quotes a Blodgett letter to the trial court about immigration enforcement making some cases more difficult. The trial court, which declined to comment on the lawsuit, later put out a policy saying that staff will not hold anyone on an ICE detainer who would otherwise normally be released.