John Moore/Getty Images/FILE
(CNN) —  

A federal judge in Massachusetts on Thursday blocked federal authorities from making civil immigration arrests inside the state’s courthouses.

US District Judge Indira Talwani issued a preliminary injunction that blocks US Immigration and Customs Enforcement and the Department of Homeland Security “from civilly arresting parties, witnesses, and others attending Massachusetts courthouses on official business while they are going to, attending, or leaving the courthouse,” according to the court order.

The order follows a lawsuit from Middlesex County District Attorney Marian Ryan and Suffolk County District Attorney Rachael Rollins, the Committee for Public Counsel Services – Massachusetts’ public defender agency, and advocacy group Chelsea Collaborative. It also comes after a Massachusetts judge and a former court officer were accused in April of helping a twice-deported undocumented defendant elude immigration authorities by slipping out a rear courthouse door.

The district attorneys’ “claim that ICE civil arrests in state courthouses, the sole forum in which they can prosecute cases, are hindering the DAs’ ability to carry out their primary functions as District Attorneys,” according to the court order, and Chelsea Collaborative claims such arrests “impair their members’ ability to protect themselves through the state courts from unlawful actions of other individuals.”

Increasing ICE arrests at courthouses during the Trump administration has caused tensions between major cities and federal officials. Local jurisdictions and attorneys have complained arresting undocumented immigrants in courthouses decreases their participation in prosecuting criminals as witnesses and reporting victims.

In the Massachusetts case, the plaintiffs argued that “victim witness advocates can no longer advise victims that their fear of arrest during the court process is unfounded,” according to the court filing.

In April, Newton District Court Judge Shelley Richmond Joseph and former trial court officer Wesley MacGregor were indicted on obstruction of justice and other federal charges for allegedly allowing an undocumented immigrant at a criminal court hearing to escape detention by an ICE officer. Joseph and MacGregor were released without bond after pleading not guilty, CNN affiliate WCVB reported.

At the time, Massachusetts Attorney General Maura Healey said the indictment was “a radical and politically motivated attack on our state and the independence of our courts.”

CNN’s Rob Frehse and Ray Sanchez contributed to this report.