A Massachusetts judge and court officer accused of helping an illegal immigrant flee an Immigration and Customs Enforcement agent waiting to take him into custody were indicted Thursday by a federal grand jury for obstruction of justice and three other counts, officials said.

Newton District Court Judge Shelley M. Richmond Joseph and the court officer, identified in court documents as Wesley MacGregor, face several charges stemming from an April 2, 2018 incident in which the pair allegedly helped Jose Medina-Perez get out of the courthouse via a back door in order to elude the ICE agent who sought Medina-Perez.

“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," U.S. Attorney for the District of Massachusetts Andrew Lelling said Thursday.

Joseph and MacGregor were both charged with obstruction of justice, aiding and abetting; obstruction of a federal proceeding, aiding and abetting and conspiracy to obstruct justice, Lelling said. MacGregor was also charged with perjury before a federal grand jury.

Joseph, who has been suspended without pay, and MacGregor appeared in court Thursday and pleaded not guilty to all counts. No date has been set for their next court appearance.

"As public servants, all of the officers in the court make a promise — a promise to serve the people’s interest above all else. Today we know this promise has been broken,” said Peter Fitzhugh, special agent in charge of the Homeland Security Investigations in Boston, who led the investigation.

Medina-Perez, a twice-deported illegal immigrant with a fugitive warrant for drunken driving in Pennsylvania, had been in Joseph's courtroom in order to be arraigned on drug charges, the Boston Globe previously reported.

RHODE ISLAND MAN THREATENED TO KILL DEMOCRATS, EAT PRO-ABORTION PROFESSOR ‘PIECE BY PIECE,’ FEDS SAY

Medina-Perez was the subject of an ICE detainer -- a written request to hold an individual wanted for deportation for up to 48 hours -- and an ICE agent was waiting in the lobby of the courthouse to detain Medina-Perez after the arraignment, officials said. But during the hearing, Joseph asked Medina-Perez’s attorney “ICE is going to get him?,” according to courtroom recordings obtained by the Boston Globe in December and released in court documents Thursday.

Medina-Perez's lawyer was also heard telling Joseph “ICE will pick him up if he walks out the front door. But I think the best thing for us to do is clear the fugitive issue and release him on a personal, and hope that he can avoid ICE...That's the best I can do.”

“What if we detain him?" the judge asked before requesting the clerk to turn off the courtroom’s audio recorder, leaving nearly a minute unrecorded.

Minutes later, Medina-Perez's attorney said his client "has some property downstairs" and needed to speak to an interpreter, which Joseph allowed.

MacGregor then used his security access card to escort Medina-Perez out of the courthouse without being seen by the ICE agent, officials said.

"With the recorder off, defendant Joseph and the Defense Attorney discussed devising a way to have A.S. [Medina-Perez] avoid being arrested by the ICE officer," court documents stated.

FORMER BOSTON TOP COP SAYS BERNIE SANDERS' PUSH TO LET FELONS VOTE SHOULDN'T APPLY TO BOSTON BOMBER

The ICE agent continued to wait in the lobby not knowing the illegal immigrant already left the building, Lelling said, adding Joseph lied about the incident to her superiors when asked about it.

"The people of this country deserve nothing less than to know that their appointed and elected representatives are working on their behalf, while adhering to and enforcing the rule of law, not a personal agenda," Fitzhugh said. "The special agents of Homeland Security Investigations remain committed to upholding our promise to the public, without compromise.”

Massachusetts Attorney General Maura Healey said in a statement the 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," she continued. "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.”

MAN WHO SENT POWDER-FILLED LETTERS TO TRUMP SONS GETS PROBATION

Joseph was appointed Newton District judge by Massachusetts Gov. Charlie Baker in 2017 after several years serving as a criminal defense attorney and a prosecutor, the Boston Globe reported.

After reports of Joseph’s alleged intervention emerged in December, Baker told reporters he believed Joseph should be benched while the incident was investigated.

"I don't believe she should be hearing criminal cases until that federal case is resolved," Baker said about Joseph. "Look, judges are not supposed to be in the business of obstructing justice. And as far as I can tell, based on the facts as they were presented, she clearly violated the court's own policies with respect to the way they're supposed to handle continuance and involve federal immigration enforcement."

CLICK HERE FOR THE FOX NEWS APP

Medina-Perez’s freedom was short-lived. He was arrested a month later after the court hearing and again let go, this time by an immigration judge who freed him on bond, the Boston Globe reported. That case is currently pending, officials said. The 38-year-old native of the Dominican Republic had been previously deported in January 2003 and June 2007, ICE said. His real name is Oscar Manuel Peguero, although he goes by several aliases.

Fox News' Nicole Darrah contributed to this report.