The exterior of the Montgomery County Courthouse in Rockville, Md. (Dan Morse/The Washington Post)

Jose Montano, the 17-year-old Maryland youth cleared of sex assault charges in a high-profile rape case last week, appeared in juvenile court Monday as his new case related to child pornography got underway.

Montgomery Circuit Judge Cynthia Callahan on Monday ordered Montano released from the custody of the county, but said he must wear an ankle monitor and stay at home unless he is going to school or attending court matters. After the hearing, though, immigration agents took Montano into custody, a signal they will pursue a deportation case against him, according to his attorneys.

The new charges in juvenile court grew out of the rape case that started two months ago at Rockville High School. A 14-year-old student there told a staff member, and then told Montgomery County detectives, that she had been forced into a boys’ bathroom stall and raped repeatedly by two classmates.

Both suspects in the alleged rape, Montano and Henry Sanchez Milian, 18, had entered the United States illegally last year, were detained at the border and were allowed to continue on to Montgomery County. Their immigration status, and the brutality of the original accusations, caught the attention of the White House and drew international notice.

Montano was charged as an adult in that case. On Friday, however, Montgomery prosecutors announced that they were dropping charges of first-degree rape and first-degree sex offense against both suspects, saying that a subsequent investigation cast considerable doubt on the original claims.

It was during that investigation that lewd images were found on Montano’s phone. And on Friday, prosecutors also announced that they were pursuing new charges against Montano in juvenile court.

Juvenile court proceedings, including charges, often are kept confidential. But Montano’s attorney, Maria Mena, said she wanted the hearing to be open and did not object to a reporter being present. She also said the case accused her client of two counts of possession of child pornography and two counts of distribution of child pornography.

Mena called the charges an “egregious” stretch of child pornography laws designed to go after adults and said that the images at the core of the juvenile case were part of text exchanges that had helped exonerate Montano of the rape accusations.

After the hearing Monday, Montano was led out a side door of the courtroom by sheriff’s deputies. He was taken to a holding cell, according to his attorneys, and arrested by U.S. Immigration and Customs Enforcement (ICE) agents.

Jose Canto, Montano’s immigration attorney, said he will seek to have Montano released from federal custody on a bond, and try to get him “back home with his family.”

Matthew Bourke, a spokesman for ICE, said he could not comment on Montano’s immigration status or whether he was in ICE custody because Montano is a juvenile.

If Montano is freed to go home to relatives, he will not be returning to Rockville High School.

Derek Turner, a school spokesman, said that if Montano and Sanchez Milian — who also faces pending child pornography charges — are released, the school system will follow state mandates and provide them with education. But they would not go to any school facilities, Turner said, and instead be taught under a program that allows certain students to be educated at their homes.

On March 16, Montgomery police had charged Montano and Sanchez Milian with one count each of first-degree rape and two counts each of first-degree sex offense after the reported rape at the high school.

Montgomery prosecutors reviewed what the girl had told detectives, spoke more with her, reviewed interior school surveillance video of hallways, and studied text messages sent between the girl and Montano, and text messages sent between Montano and Sanchez Milian.

“The facts of this case do not support the original charges filed,” Montgomery County State’s Attorney John McCarthy said Friday.

Sanchez Milian remains held in the Montgomery County jail. His attorney, Andrew Jezic, also criticized the new pornography charges, saying they were a stretch given that so many teenagers text lewd photographs to one another.