The 16-year-old girl was due to be sentenced this morning over the killing of Katie Rough on a playing field in York in January.
A judge instead ordered that the teenager be admitted to secure hospital so doctors could obtain the "fullest picture" of her mental condition.
Mr Justice Soole said he was making the interim hospital order after being given the opinion of three specialists who have assessed the defendant.
The teenager, who cannot be identified, put her head in her hands and sobbed as the judge explained the decision.
She appeared before Leeds Crown Court via a video link from a different room within the court building.
The teenager, wearing jeans and grey hooded top, did not answer when asked to confirm her name by the court clerk.
A solicitor sat beside defendant confirmed her identify.
The judge said: "An interim hospital order involves a short-term period of specialist medical assessment in hospital pending a final decision as to how the case should be dealt with.
"It may be made where the court is satisfied, on the evidence of two registered medical practitioners, that the offender is suffering from mental disorder and that there is reason to suppose that the disorder is such that it may by appropriate for a hospital order to be made on the final disposal of the case."
Passing the order, he told the teenager: "I do so in order to try and obtain the fullest picture of your mental condition and its prospects of treatment before making my final decision as to the appropriate sentence in your case."
The order will remain in place until November 24 this year, when the teenager will next appear before the court.
On that date the judge will have the power to renew the order for a further 28 days.
The judge added: "I emphasise that this is an interim order only. Accordingly all sentencing options will be open when, at its conclusion, I make my final decision."
Katie was found with severe lacerations to her neck and chest on January 9 and did not respond to frantic attempts to revive her.
A court hearing in July was told Katie died from being smothered by her attacker.
The teenager, aged 15 at the time, was standing in a nearby cul-de-sac, covered in blood and carrying a blood-stained Stanley knife as she rang 999 to tell police what she had done.
The judge was told she may have been trying to prove the youngster was not a robot, as she had "irrational beliefs" about how people "may not be human and may be controlled by a higher and hostile force", a court heard earlier this year.
The girl denied murder but pleaded guilty to manslaughter by diminished responsibility.
That plea was accepted by the prosecution.
Mr Justice Soole heard how the girl began suffering from mental health problems more than a year before the killing.
Prosecutors said she had reported delusional thoughts as well as depression, self-harm and suicidal thoughts.
They said the girl had talked of being convinced that people "weren't human and were robots".
The girl became distressed when one doctor asked her after the killing "whether she killed Katie to test whether she was a robot".
The court heard that, although psychosis was being investigating prior to the killing, it had not been diagnosed.
Nicholas Johnson QC, defending, told the last hearing it may be his client was "driven by the irrational belief (Katie) may not have been human and needed proof of this".
He said the teenager had thoughts that people around her "may not be human and may be controlled by a higher and hostile force".
The barrister said his client had posted a picture on social media two days before the killing with a concerning message.
He said: "She was clearly crying out for help and support."
In July, the judge said he wanted more questions answering by medical experts before he could pass sentence, and apologised to Katie's family for the delay.