Judge Joseph was a visiting judge in the courthouse, occasionally hearing cases on Tuesdays.

Mr. Medina-Perez, who also went by the name Oscar Peguero, had been arrested in Newton on narcotics charges, and had been linked to an eight-year-old warrant for drunken driving from Pennsylvania. He had been deported twice from the United States, and the second time, in 2007, he had been prohibited from entering the country for 20 years, according to the federal indictment.

At 12:04, while Mr. Medina-Perez was sitting in the glass dock to the right of her bench, Judge Joseph instructed the court clerk to ask the ICE officer to leave the courtroom and wait in the lobby outside. According to defense briefs, the judge was complying with established policy at the Newton courthouse at the time.

Only later would it become clear what had happened inside, as Judge Joseph held a sidebar conference with the assistant district attorney and Mr. Medina-Perez’s defense attorney. Both agreed that Mr. Medina-Perez was not the man wanted in Pennsylvania.

He could have been released on bond from the jail in Billerica, Mass., but the defense attorney, David Jellinek, jumped in.

Defense Attorney: There is an ICE detainer. So if he’s bailed out from Billerica when he goes back there, ICE will pick him up — Judge Joseph: ICE is gonna get him? Defense Attorney: Yeah. Judge Joseph: What if we detain him? Defense Attorney: Are we on the record? Judge Joseph: {Clerk,} can we go off the record for a moment? Clerk: What’s that? Judge Joseph: Are we off the record? Clerk: No, we’re on the record. Defense attorney: Can we go off the record for a moment?

At this point, according to the indictment, the clerk switched off the courtroom recorder for 52 seconds, in violation of Massachusetts courtroom rules. When the recording picked up again, the three resumed their conversation, agreeing to release Mr. Medina-Perez — but not, as is usual, through the courtroom lobby. (Mr. Jellinek declined to comment for this article.)

Defense attorney: I would ask that he, uh — I believe he has some property downstairs. I’d like to speak with him downstairs with the interpreter if I may. Judge Joseph: That’s fine. Of course. Defense attorney: Thank you.

Seven minutes later, the indictment reflects, Mr. Medina-Perez departed through the courthouse’s rear exit, which opens into a public parking lot. But this was not communicated to the ICE officer, who remained in the lobby. The courthouse closes its doors at 4:30 p.m., seven hours after the ICE officer showed up.

He departed empty-handed and, presumably, frustrated.