Newton District Court Judge Shelley Richmond Joseph was offered a deal to avoid prosecution if she admitted she helped an illegal immigrant escape out a basement door in the courthouse to avoid ICE agents last year, the Herald has learned.

The deal that Joseph turned down was offered up by U.S. Attorney Andrew Lelling’s office, a source familiar with the matter told the Herald.

Joseph, 51, of Natick, was indicted last month on federal charges of obstruction of justice and aiding and abetting for allegedly interfering with a federal investigation. The state Supreme Judicial Court quickly announced it had suspended Joseph without pay, effective immediately. She was earning $184,694 a year.

In addition to Joseph, the grand jury indicted former $83,344-a-year Trial Court officer Wesley MacGregor, 56, of Watertown, on charges of obstruction of justice and aiding and abetting, as well as perjury.

Joseph and MacGregor have both pleaded not guilty and Judge Jennifer Boal released them both on their own recognizance.

Joseph’s attorney, Thomas Hoopes, declined comment, as did Lelling’s office, when asked about the deal by the Herald.

A motion filed Thursday stated that both the prosecutors and defendants “intend to seek a protective order regarding the dissemination of certain

sensitive information.” What that information is was not revealed.

A status conference is set for May 30 in the case as both sides prepare for a trial, court records state.

Joseph faces up to 20 years in prison if found guilty of allowing the illegal immigrant to bolt out the basement door.

Lelling said last month the illegal immigrant was captured about a month after the April 2, 2018, incident in Newton District Court and is facing deportation proceedings. The indictment states the man had been previously deported in 2003 and 2007.

In addition to breaking Trial Court rules, prosecutors allege Joseph lied about the matter to her superiors.

The feds have faced criticism for charging a sitting state judge over an illegal immigrant case. Lelling said last month he doesn’t play favorites.

“If the law is not applied equally, it cannot credibly be applied to anyone,” Lelling said at a press conference in late April.

“Are judges special? Sure,” he added. “But not because of the privileges they have enjoyed. They’re special because they’re entrusted with enormous power. They explicitly swear to uphold the law and they are given life tenure under the state constitution.”