A federal grand jury has indicted a Massachusetts judge and court officer for helping an illegal immigrant elude federal immigration authorities after his arraignment in Newton District Court last year.

The judge, Shelley M. Richmond Joseph, a former criminal defense lawyer, and Wesley Macgregor, a court officer, were indicted Tuesday morning on counts of obstruction of justice, conspiracy to obstruct justice, and aiding and abetting obstruction of a federal proceeding. Macgregor, 56, of Watertown was also indicted on one count of perjury for, prosecutors say, lying to a grand jury.

Joseph, 51, of Natick, was the judge at the arraignment of an illegal immigrant, Jose Medina-Perez, who came before her on April 2, 2018 on charges of drug possession and being a fugitive from justice in Pennsylvania after Newton police arrested him.

His fingerprints matched those of a man twice deported before who had been ordered not to return to the country until at least 2027. So the U.S. Immigration and Naturalization Service sent an agent to Newton District Court on April 2, 2018 to pick him up after his arraignment.

The ICE agent arrived at the courthouse about 9:30 a.m. and identified himself to court personnel and told them what he was there to do, according to the indictment.

At about 10:34 a.m. the judge assigned the defendant a lawyer and said she would call the case later in the day, which she did at 12:04 p.m., according to the indictment. The ICE agent was waiting in the courtroom during the arraignment, which by law is an open court proceeding – but the judge had the clerk order the ICE agent out of the courtroom, telling him to wait in the lobby, according to court papers.

At 2:48 p.m., the case was called again and the judge discussed the case with the defense lawyer and prosecutor. Most of the conversation was tape recorded; a transcript shows the three lawyers discussing how vulnerable the man was to being detained and deported

“ICE is gonna get him?” the judge said at one point, according to the transcript.

A short time later the judge ordered the clerk to turn off the audio recorder to hold an off-the-record discussion – against Massachusetts court rules – which lasted about 52 seconds.

When the recording resumed, the judge and the two lawyers discussed dismissing the fugitive count, which the judge did, and how the prosecutor didn’t want the defendant held on the drug possession account. Then the defense lawyer asks the judge a question:

Defense Lawyer: “I would ask that he, uh — I believe he has some property downstairs. I’d like to speak with him downstairs with the interpreter, if I may.”

Judge Shelley Joseph: “That’s fine. Of course.”

According to federal prosecutors, the court officer, Macgregor, escorted the defendant (referred to as the “Alien Subject” in court papers) to the lockup downstairs with the defense lawyer and an interpreter.

“Once inside the lockup, defendant MACGREGOR used his security access card to open the rear sally-port exit and released A.S. out the backdoor at approximately 3:01 p.m.,” the indictment states. “… The ICE Officer, who had been instructed by the Clerkto wait for [Alien Subject] in the lobby directly outside the Courtroom, as that was where [Alien Subject] would have been released in accordance with customary [Newton District Court] practice, was unaware of [Alien Subject’s] release out the rear sally-port exit, and was unable to take custody of A.S. pursuant to the Warrant.”

Joseph had been a district court judge since November 6, 2017, or a little less than five months, when the incident occurred. She was appointed by Governor Charlie Baker, a Republican.

U.S. Attorney Andrew Lelling, a Republican appointee of President Donald Trump, said the judge’s actions are unacceptable.

“This case is about the rule of law. The allegations in today’s indictment involve obstruction by a sitting judge, that is intentional interference with the enforcement of federal law, and that is a crime,” Lelling said in a written statement Thursday, April 25. “We cannot pick and choose the federal laws we follow, or use our personal views to justify violating the law. Everyone in the justice system – not just judges, but law enforcement officers, prosecutors, and defense counsel – should be held to a higher standard. The people of Massachusetts expect that, just like they expect judges to be fair, impartial and to follow the law themselves.”

An ICE administrator castigated the judge.

“The actions of the judge in this incident are a detriment to the rule of law and highly offensive to the law enforcement officers of ICE who swear an oath to uphold our nation’s immigration laws,” said Todd M. Lyons, acting field office director of the Boston office of ICE, in a written statement. “In order for our criminal justice system to work fairly for all people, it must be protected against judicial officials who would seek to replace the implementation of our laws with their own ideological views or politically-driven agenda.”

Lawyers for Joseph and Macgregor could not immediately be reached for comment Thursday afternoon.