A 16-year-old who has been under psychiatric care since he was arrested in the May shooting of a D.C. police officer was convicted Tuesday of attempted second-degree murder while armed.

The conviction was part of an Alford plea agreement, in which a defendant does not admit guilt but acknowledges that the government has enough evidence for a conviction. What’s next for the teen is unclear. Scheduled for sentencing Nov. 22, he was charged as a juvenile and could be committed to the custody of the District’s Department of Youth Rehabilitation Services until age 21.

But his attorney, Antoini Jones, said during a hearing Tuesday that the teen was no longer a danger to himself or anyone else and should be released into his mother’s care.

The teen suffered from undetected psychological problems at the time of the May 21 shooting, Jones said. He was “very religious,” Jones said, and — as had been advertised by a California preacher — believed the world was coming to an end when police found him on the awning of his apartment building with a gun.

The teen did not remember shooting at three police officers, said Jones, but instead thought he was in a jungle shooting at lions. “This young man, unbeknownst to anyone, had a psychological problem,” Jones said.

Since the shooting, he has been given medication and evaluated four times at the Psychiatric Institute of Washington.

During the hearing, the teen spoke in a soft voice as he told D.C. Superior Court Judge Milton C. Lee Jr. that he was using his medication and that it “made me feel good.”

But although Lee noted that reports from counselors and therapists indicated that the teen had shown progress, he said he needed additional evaluations to determine whether the teen could be released from custody.

Lee ordered a risk assessment and another psychological test.

“I have to be practical about this,” Lee said. “He just pled guilty to shooting a police officer. Can I release him into the community safely without jeopardizing him or other people?”

The Washington Post was permitted to cover the hearing on the condition that the teen and his family not be identified.

The teen, who was 15 at the time of the shooting, was arrested after the shooting of a police officer who had responded to the 700 block of Crittenden Street NE about 5:15 a.m for a report of a man with a gun. When uniformed officers arrived, they found the teen on the awning of his apartment with a .38 revolver, authorities said.

One officer, who was wearing a protective vest, was hit three times, once in the neck. Another officer was grazed. In exchange for the plea, prosecutors agreed to drop several other charges.

A trial in the case had been delayed while the teen underwent numerous psychological evaluations to determine whether he was fit to stand trial. It was scheduled to begin Tuesday.

Jones, the judge and prosecutors agreed it was unclear what triggered the teen’s psychological episode, another reason additional tests were ordered.