A Middlesex County judge and former court officer are facing federal charges for allegedly helping a defendant in a Newton courtroom avoid arrest by an immigration officer last year.

Judge Shelley Richmond Joseph and now-retired court officer Wesley MacGregor are accused of helping the defendant, an undocumented immigrant, slip out the back door of Newton District Court while an Immigration and Customs Enforcement agent waited to arrest him on a federal detainer in April 2018.

Joseph and MacGregor are facing three different obstruction charges: conspiracy, aiding and abetting, and obstruction of a federal proceeding. MacGregor, a trial court officer from 1993 until his retirement last month, was additionally charged with perjury for allegedly lying to the grand jury when he said he wasn't aware of an ICE officer in the courthouse that day.

The two defendants pleaded not guilty to all charges at appearances in Boston federal court Thursday afternoon, and were released.

The Massachusetts Supreme Judicial Court ordered Joseph be suspended without pay.

"This order is based solely on the fact that a sitting judge has been indicted for alleged misconduct in the performance of her judicial duties. It in no way reflects any opinion on the merits of the pending criminal case," the court wrote.

Speaking to reporters, U.S. Attorney Andrew Lelling said this case is neither an indictment on the state's trial court system nor about immigration policy.

“It is about the rule of law,” he said.

Lelling said he has heard gasps from certain quarters throughout the investigation from people surprised his office would pursue charges against a sitting judge.

“We did not bring this case in response to the public debate over immigration enforcement. There are reasonable arguments on both sides of that debate,” Lelling said. “But this isn’t a policy seminar, it’s a law enforcement action.”

Massachusetts Attorney General Maura Healey, a Democrat, issued a strong rebuke in response to Lelling's indictment, writing:

Today’s indictment is a radical and politically-motivated attack on our state and the independence of our courts. It is a bedrock principle of our constitutional system that federal prosecutors should not recklessly interfere with the operation of state courts and their administration of justice. This matter could have been appropriately handled by the Commission on Judicial Conduct and the Trial Court. I am deeply disappointed by U.S. Attorney Andrew Lelling’s misuse of prosecutorial resources and the chilling effect his actions will have.

Republican Gov. Charlie Baker, who nominated Joseph to the bench in 2017, said in December 2018 that he wanted her removed.

Susan Church, a Cambridge immigration attorney, said the case would worsen fears about the court system for undocumented immigrants.

"We have witnesses who won't come to court. We have defendants who don't get tried. We have people who can't get divorced — women who can't seek restraining orders because they are terrified by ICE interference," she said.

The defendant isn't named in the indictment, but has been previously identified as Jose Medina-Perez, 38, from the Dominican Republic. In April 2018, he was facing drug charges and a fugitive warrant out of Pennsylvania for drunken driving. Immigration officials say the defendant's real name is Oscar Manuel Peguero. According to Lelling's office, Peguero has been deported from the U.S. twice — in 2003 and 2007 — and a federal order had been issued prohibiting him for re-entering until 2027.

The incident was first reported by The Boston Globe last December. Courtroom recordings allegedly caught the judge, state prosecutor and defendant's attorney talking about the ICE agent looking for Peguero.

Peguero was picked up by police later in April 2018.

With additional reporting from WBUR's Ally Jarmanning and Lisa Creamer, as well as The Associated Press and NPR