Washington (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.

Read More