The two allegedly allowed the man to exit through a courthouse back door while an immigration officer waited outside to arrest him.
Boston-area judge Shelley Joseph and Wesley MacGregor have been charged with conspiracy and obstruction of justice.
The man was in court on drug charges and for being a fugitive from justice.
In their first court appearance on 25 April, both Judge Joseph, 51, and Mr MacGregor, 46, pleaded not guilty and were released.
According to court documents, an agent from Immigration and Customs Enforcement (Ice) attended an April 2018 hearing for the man in a Newton, Massachusetts district court with the intention of apprehending him.
The suspect, unidentified in court documents, was named Jose Medina-Perez, according to local media.
The Dominican Republic native had reportedly been deported from the US twice, in 2003 and 2007, the Boston Globe reported.
Court documents cite an order, issued upon his second removal, that prohibits Mr Medina-Perez from entering the US until 2027, according to the newspaper.
Is there a crisis on the US-Mexico border?
US reverses deportation of husband of soldier killed in Afghanistan
Militia detains migrants at gunpoint along the US-Mexico border
The suspect’s lawyer allegedly told Judge Joseph he thought that Ice had the wrong man.
The indictment describes a subsequent conversation, captured by the court recorder, between Judge Joseph and the lawyer regarding his client’s pending arrest.
“Ice is gonna get him?” she allegedly asked, adding “I’m not gonna allow them to come in here.”
Prosecutors say Judge Joseph then arranged for Mr Medina-Perez to exit through a rear door as the Ice agent waited for the suspect in the lobby of the courthouse.
Judge Joseph and Mr MacGregor were both charged with one count of conspiracy to obstruct justice and two counts of obstruction of justice. Mr MacGregor was also charged with perjury.
The judge has been suspended without pay by the state Supreme Judicial Court judicial. Mr MacGregor recently retired from his position as court officer last month.
US Attorney Andrew Lelling, the top federal prosecutor in the state, said the charges were not meant as a political statement.
“This case is about the rule of law,” Mr Lelling said.
“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.”
But the charges were met with almost instant rebuke from state attorney general Maura Healey, who called the indictment a “radical and politically motivated attack on our state and the independence of the court.”
The Massachusetts chapter of the American Civil Liberties Union called the case “preposterous, ironic, and deeply damaging to the rule of law”.
“This decision seems to have little to do with the actual facts, and everything to do with enforcing the president’s anti-immigrant agenda.”
The charged rhetoric underscores mounting tensions over President Donald Trump’s administration and its immigration crackdown.
Last month, US officials said the US-Mexico border was at a “breaking point” amid an “unprecedented” surge in migrant numbers.