Updated

A Massachusetts federal judge on Thursday blocked Immigration and Customs Enforcement (ICE) from arresting certain undocumented immigrants in and around courthouses in the state while a lawsuit against the practice continues to be litigated.

In issuing an injunction, U.S District Judge Indira Talwani said immigration agents would be barred from  arresting people for civil immigration violations while they are “parties, witnesses, and others attending Massachusetts courthouses on official business."

IMMIGRANT-RIGHTS GROUPS ASK SUPREME COURT TO DELAY DECISION ON 2020 CENSUS

The ruling was the result of a lawsuit filed by Boston-area district attorneys -- Middlesex County's Marian T. Ryan and Suffolk County's Rachael Rollins. Both said authorizing the arrests of undocumented immigrants in courthouses would hamper their ability to prosecute cases.

President Trump blasted Ryan and Rollins last month, shortly after the suit was filed.

“These are people that probably don’t mind crime, they don’t mind what’s going on,” Trump said during a Boston Herald Radio interview,

TAXPAYERS PAID $127G IN LEGAL BILLS FOR JUDGE ACCUSED OF HELPING ILLEGAL IMMIGRANT AVOID ICE: REPORT

Talwani said the ruling doesn't apply to undocumented immigrants already in civil or federal custody, such as when a defendant is brought from jail to a court hearing.

Rollins told Fox News she was "thrilled" with the ruling, adding that, along with her staff, she looks forward to "continuing our vital work in courthouses across Suffolk County that will be positively impacted by today’s ruling."

An ICE spokesman told Fox News that while the agency “respects that the court has issued its ruling, we are currently reviewing the court’s decision."

The injunction will stay in place while the case makes its way through the courts. The Justice Department is expected to appeal.

Thursday's injunction comes weeks after a Massachusetts judge in a separate case was suspended and indicted for allegedly preventing ICE from arresting a twice-deported drug suspect last year.

CLICK HERE TO GET THE FOX NEWS APP

Courthouse immigration arrests have angered immigration advocates and civil liberties groups who say the buildings are "sensitive locations" that ought to be free from immigration enforcement activity.

The New York State Office of Court Administration recently barred immigration agents from making courthouse arrests without judicial warrants or orders.

The Associated Press contributed to this report.