BOSTON (AP) — Prosecutors in Massachusetts sued Monday to block federal authorities from making arrests at courthouses of people suspected of being in the country illegally, arguing the practice is making it harder for them to hold defendants accountable and get justice for victims.

The top prosecutors for Suffolk County, which includes Boston, and Middlesex County say in the lawsuit joined by public defenders and others that some cases are grinding to a halt because witnesses, victims or defendants are too afraid to come to courts staked out by immigration agents.

"When we cannot hold anyone accountable for their actions — let me be clear — that is not justice and not one person in this commonwealth is safer because of that practice," Middlesex County District Attorney Marian Ryan told reporters.

Read more: 2 Mass. DAs, Public Defenders Coalition File Federal Lawsuit To Stop ICE Arrests At Courthouses

The federal lawsuit, believed to be the first of its kind in the country, is the latest fight between state and federal authorities over President Donald Trump's stepped-up immigration efforts.

It comes days after federal prosecutors in Massachusetts charged a state court judge and former court officer with obstruction of justice for allegedly helping a man sneak out a back door of the courthouse to evade a waiting immigration agent.

Such courthouse arrests, which immigrant advocates say have increased across the country under Trump, have led to protests by lawyers representing immigrants and calls for an end to the policy from current and retired judges . Earlier this month, New York state courts officials barred immigration agents from making arrests inside courthouses without judicial warrants or orders.

The Trump administration has said it's only going to halls of justice for certain targets, like public safety threats, and that courthouses are among the safest places to arrest immigrants because visitors typically have to go through metal detectors.

A U.S. Immigration and Customs Enforcement spokesman declined to comment Monday.

But Bristol County Sheriff Thomas Hodgson slammed prosecutors for bringing the case, saying they should be "working with law enforcement instead of partnering with criminal illegal immigrants."

The lawsuit seeks to bar federal authorities from arresting people for civil immigration violations while they're coming to, leaving or are inside a courthouse. The lawsuit does not aim to block immigration agents from arresting people who are brought in court while in state custody on a criminal charge.

Ivan Espinoza-Madrigal of Lawyers for Civil Rights, one of the groups bringing the case, said it's the first federal lawsuit challenging ICE's practice of courthouse arrests.

READ MORE: Rollins, Ryan Launch Cold Case Initiative To Get To The Bottom Of Real-Life Murder Mysteries

"This case creates a blueprint for advocates across the country who want to protect immigrants," the executive director said.

A judge on Massachusetts' highest court last year rejected a similar state court case that sought to bar agents from arresting immigrants at courthouses.

Among other things, the federal lawsuit argues that the practice violates the constitutional right to access the courts.

"I am not asking nor am I intending to interfere with the federal government when they engage in and exercise their lawful authority," Suffolk County District Attorney Rachael Rollins said. "I simply ask that they pay us the same respect and not interfere with ours."

Lawyers said they don't have data on how many cases have been disrupted by ICE arrests, but say immigration arrests are reported at courthouses across the state several times a week. Ryan said her office has seen two cases that were interrupted because someone needed in court disappeared during the day.

The complaint cites several cases of victims being too afraid to come forward because of the courthouse arrests. For example, immigrants who were duped into investing in a shell company have refused to bring a case against the fraudster to get their money back because they fear they could be arrested and deported if they have to show up in court, the lawsuit says.

"Our courts are places where individuals, regardless of income or influence or status must be able to seek justice, to exercise their constitutional rights, to seek safety from physical harm or compensation for economic harm," said Wendy Wayne, director of the immigration impact unit at Massachusetts' public defender agency, the Committee for Public Counsel Services.