A 15-year-old African American student from Michigan was incarcerated in mid-May after arguing with her mother about online schoolwork.
The case has caused outrage in the United States with protesters saying it highlights systemic racism in the judicial system and the criminalisation of black people.
Oakland County Judge Mary Ellen Brennan said the girl was placed in a juvenile facility for violating probation in a case involving allegations of assault and theft.
“She was not detained because she didn't turn her homework in … she was detained because she was a threat to her mother," Ms Brennan said, according to The Detroit News.
“My role is to make decisions that are in this young lady's best interest, period… I took an oath that I would not be swayed by public clamour or fear of criticism.”
The teenager, who is identified only by her middle name Grace, pleaded with the court for her freedom.
“I miss my mum. I can control myself. I can be obedient,” she said.
The girl's mother told ProPublica "it just doesn’t make any sense,” to keep her daughter, who has ADHD and learning difficulties, imprisoned.
But, ProPublica reported that the Family Division judge told the 15-year-old to first finish a treatment program she had started at Oakland County's Children's Village.
"Give yourself a chance to follow through and finish something," Ms Brennan said.
“The right thing is for you and your mum to be separated for right now."
Students and community members protested outside the court building on Monday.
“People need to learn how to work with our kids… there needs to be equitable treatment of all kids, and we need to realise there isn’t,” protester Monique Campbell told TIME magazine.
Another protester Vivian Anderson told TIME black children are being criminalised for “behaviour that’s accepted in other communities as a way of life ... this is their ageing process.”
Another hearing has been set for September, at which time the girl will have been incarcerated for four months.