Updated June 21, 8:30 a.m.

A new ruling from a federal judge prevents Immigration and Customs Enforcement (ICE) from making civil immigration arrests in Massachusetts courthouses.

U.S. District Court Judge Indira Talwani's motion to allow a preliminary injunction, issued Thursday, bars ICE agents from making civil arrests of anyone entering, attending or exiting a Massachusetts court, unless they're already being held by state or federal authorities. Criminal immigration arrests are still legal.

This follows an April 29 lawsuit from Middlesex District Attorney Marian Ryan, Suffolk District Attorney Rachael Rollins, the Committee For Public Counsel Services, and the Chelsea Collaborative Inc., who argued that it’s difficult for prosecutors to hold defendants accountable if they can be arrested in courthouses.

Oren Nimni, an attorney with the Lawyers' Committee for Civil Rights of Boston, helped file the suit. He says ICE officials were “stalking” people who appeared in Massachusetts courtrooms and making them afraid to come to court.

“The impact that this was having on immigrant communities was incalculable,” Nimni said. “Victims of domestic abuse that want to get a restraining order against an abusive partner were now too afraid to go to court. People that wanted to sue their bosses for unpaid wages were now too afraid to bring their case to a court. … We brought this case to stop ICE from patrolling the courthouses, intimidating clients and witnesses and victims, and arresting people on civil immigration detainers.”

Nimni also said he saw a significant spike in ICE arrests after President Donald Trump’s election and the implementation of new ICE directives specifically targeting Massachusetts.

“We saw ICE enforcement activities at 23 different courthouses across the state of Massachusetts, and we were tracking upwards of 40 arrests a month,” Nimni said. “It went from something that didn't happen at all to something that was a regular presence at a number of Massachusetts courthouses.”

Rollins said in a statement that she is "thrilled" with the ruling.

"As my staff and I closely review the decision, we look forward to continuing our vital work in courthouses across Suffolk County that will be positively impacted by today’s ruling," she said in the statement. "I join DA Ryan, CPCS, and the Chelsea Collaborative in celebrating this moment, and look forward to addressing the media in the coming days to discuss what this important ruling means for the communities we serve.”

In a statement, Ryan said Massachusetts is, "as we always have been, leaders in protecting the most vulnerable members of our community."

"This decision reaffirms that every person in our Commonwealth should be able to seek justice in our courts without fear or hesitation. The granting of this injunction is a critical step in the right direction for our Commonwealth and it should be a model for our nation,” she said in the statement.

John Mohan, an ICE spokesman, said in an email that the agency is reviewing the court's decision and has no further comment, according to the Associated Press.