Newton District Court Judge Shelley Joseph, who is accused of helping an undocumented man in her courtroom evade federal immigration agents, asked a federal judge to dismiss the case against her on the grounds that it would limit judicial independence.

Joseph, who was indicted in April, called the prosecution “unprecedented” and argued that prosecuting a judge used her discretion to manage the courtroom, even if the judge errs in doing so, would undermine a judge’s authority.

“There is a reason why no state judge has ever been prosecuted for not facilitating the immigration policies of the federal government," Joseph wrote in a memorandum filed Friday. “The reason is clear: This prosecution flies in the face of established common-law immunity principles, the plain language of the federal obstruction statutes, and the bedrock constitutional principles that underlie our federal system of dual sovereignty.”

Joseph and former Trial Court Officer Wesley MacGregor were arrested in April on charges of conspiracy to obstruct justice, obstruction of justice, obstruction of a federal proceeding and perjury.

The case is centered around Jose Medina-Perez, an undocumented man who was facing deportation after a drug arrest in Newton and an outstanding warrant for drunk driving in Pennsylvania.

Medina-Perez, who had previously been deported, was being arraigned in Joseph’s courtroom in March 2018 when a plainclothes ICE agent entered the courtroom. Prosecutors allege that Joseph ordered the agent out of the courtroom and had the courtroom recorder turned off while she discussed Medina-Perez’s ICE detainer with his defense attorney.

Joseph allegedly ordered to have him released without bail and had MacGregor take him downstairs. Prosecutors say that MacGregor let Medina-Perez leave through a back door.

Joseph was suspended from work without pay, but got her $184,000 salary reinstated in August. She also requested to go back to work to perform administrative duty, which was denied.