A 17-year-old student at Friendship Collegiate Academy pleaded guilty Wednesday to a juvenile charge of sexually assaulting a classmate at the school just 24 hours earlier.

The attack on a 16-year-old female student at the Northeast Washington public charter high school occurred about 3 p.m. Tuesday, near the end of the academic day.

Prosecutors said the male teenager was standing outside a school computer lab and groped the classmate as they waited to get keys to the lab. Once inside, the boy turned off the lights, blocked the girl from leaving the classroom and raped her, prosecutors said.

After the attack, the girl ran into the hallway in tears. Prosecutors said a security camera showed the victim sitting in the hallway crying after the attack.

The victim told one of her classmates; then they contacted a school official who called police.

Prosecutors said the six-foot, 180-pound defendant is significantly larger than the victim.

The Washington Post generally does not name victims of sex crimes or defendants charged in juvenile court. A reporter was permitted to attend the juvenile proceeding Wednesday on the condition that neither the suspect nor the victim would be named.

The accused teen, standing next to his two attorneys from the District’s Public Defender Service made his first appearance in court after his arrest. His attorneys then told the judge that their client planned to plead guilty.

The judge asked the teen why he was pleading guilty.

“ ’Cause it’s true,” the teen said.

The defendant’s father, who was present with the teen’s mother, pleaded with the judge to release his son into his care. “He’s not a troublesome kid. Jail is not the place for him,” his father said.

One of his attorneys told the judge that the defendant was a good student but would not be returning to the school because of the incident. But at the time of Tuesday’s attack, the teen was under court supervision after a December arrest for possession of a BB gun.

The judge ordered the teen to be held at the Youth Services Center until he is sentenced April 4. The judge also ordered the teen to undergo a psycho-sexual evaluation and to stay away from the victim.

The school’s principal, Peggy Jones, said school officials were cooperating with D.C. police. “We do want to make sure that this is always a safe and orderly environment for our young people,” Jones said.

Emma Brown contributed to this report.