A judge has been charged with obstruction of justice for allegedly helping a man in the country illegally to evade immigration officials - after he was allowed to leave the building through a back door.

Newton District Court Judge Shelley M Richmond Joseph has also been charged with conspiracy to obstruct justice and obstruction of a federal proceeding, NBC reports. Former court officer Wesley MacGregor was also indicted on the charges, as well as perjury.

The defendant in question had been deported twice before and was identified by Immigration and Customs Enforcement by his fingerprints after being arrested for narcotics possession four days prior to his court appearance in April last year.

ICE then issued a federal immigration order and sent an officer to the courthouse, where the immigrant’s defence lawyer alerted Judge Joseph of the officer’s presence.

"ICE is going to pick him up if he walks out the front door," the defence lawyer told the judge in a sidebar that was recorded.

Still being recorded, Judge Joseph suggested they detain him, and then requested the courtroom recorder to be turned off. It was off for 52 seconds.

When the recording continued, the prosecutor agreed with the defence lawyer that the case should be dismissed, saying it was likely a case of mistaken identity.

‘Families belong together’ protests over Trump immigration policy Show all 8 1 /8 ‘Families belong together’ protests over Trump immigration policy ‘Families belong together’ protests over Trump immigration policy Mishawaka, Indiana AP ‘Families belong together’ protests over Trump immigration policy Washington DC AFP/Getty Images ‘Families belong together’ protests over Trump immigration policy New York Mayor Bill De Blasio speaks in Tornillo, Texas alongside the many other US mayors who have called for detained immigrant children to be reunited with their families AP ‘Families belong together’ protests over Trump immigration policy Albuquerque Mayor Tim Kelle leaves a teddy bear as a gift for detained immigrant children in Tornillo, Texas AP ‘Families belong together’ protests over Trump immigration policy Seattle Mayor Jenny Durkan and Los Angeles Mayor Eric Garcetti leave sandals as gifts for detained immigrant children in Tornillo, Texas AP ‘Families belong together’ protests over Trump immigration policy San Diego, California EPA ‘Families belong together’ protests over Trump immigration policy US embassy, Mexico City AFP/Getty Images ‘Families belong together’ protests over Trump immigration policy San Diego, California EPA

Judge Joseph requested he be taken downstairs for further questioning, which allowed him to be released through a back door by MacGregor.

"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. "We cannot pick and choose the federal laws we follow, or use our personal views to justify violating the law."