A New Mexico man who killed five family members as a teenager previously was set to walk free next week on his 21st birthday, but a judge Thursday ordered him moved from a treatment center for minors into an adult jail while his juvenile sentence faces another review.

The decision by Judge Michael E. Martinez came at the end of a tense and crowded hearing in Children's Court, during which prosecutors called on a sheriff's deputy to recount how Nehemiah Griego confessed to killing his parents and three young siblings in 2013. He was 15 at the time.

Prosecutors argued that the crime justified keeping him in custody as his sentence goes through another round of court hearings following their appeal of his planned release. The judge agreed, though he seemed to waver initially on whether to send Griego to an adult or juvenile detention facility, given his status as a youthful offender who is now an adult.

"He hasn't had a chance to mature in an adult world," Martinez said.

The jail where Griego will be held must take additional steps to ensure his safety. Defense attorney Stephen Taylor said he plans to ask the court to revisit the decision and consider other placement options that would allow for Griego to continue rehabilitative treatment.

Until recently, Griego had been expected to complete his juvenile sentence and leave state custody on Tuesday. A Children's Court ruling two years ago found he had been receptive to treatment for schizoaffective disorder and post-traumatic stress disorder.

But an appeals court last week ordered a judge to hold another hearing to determine whether Griego has proven he is prepared to rejoin society. It said the judge had not considered certain testimony presented by prosecutors the first time around.

Authorities said Griego killed his family at their home south of Albuquerque in January 2013. In a chilling criminal complaint, Bernalillo County sheriff's deputies said Griego first shot his mother in her bed as she slept, then his 9-year-old brother, followed by his two sisters, ages 5 and 2.

Hours later, his father returned home, and the teen — who had been waiting in a bathroom — ambushed him, authorities said. He then spent much of the day at the Calvary Church, where his father had been a pastor.

After the shootings, Griego told a deputy that he had anger issues and had been annoyed with his mother before carrying out the attack, according to sheriff's documents.

His attorneys have argued that Griego was abused at home and likely suffered a traumatic brain injury as a result of beatings by his father. They also have described Griego's childhood as largely isolated outside of church.

In the years since, Griego has received hundreds of hours of individual, group and family therapy, according to his attorney, Taylor. Griego also has earned a high school diploma and began taking community college and vocational classes.

"Nehemiah's latest psychological evaluation confirms substantial progress and readiness for reintegration into society," Taylor said in a statement.

A new hearing to determine whether Griego will be sentenced as a juvenile or an adult has not been scheduled.

Prosecutors again will push for Griego to face an adult term for two counts of second-degree murder and three counts of child abuse resulting in death, saying the shootings were planned and alleging that he has threatened people while in custody.

In a recent court filing, prosecutors cited "generalized" threats Griego is accused of making toward others.

Griego's attorneys have called the threats unsubstantiated. A state police investigation earlier this year did not uncover any direct, criminal threats by Griego, according to a police spokeswoman.

"We have a defendant who continues to have anger issues — the same anger issues that led to the mass homicide," prosecutor James Grayson said.