The boy aged 16 strangled and tried to decapitate his seven-year-old neighbour, who was playing video games at his home, before leaving her body in a skip in Vienna in May.
The 16-year-old, who had no prior convictions, said he had been directed by "voices".
Vienna's criminal court sentenced him late Wednesday to a 13-year prison term -- close to the maximum that could have been given to an offender of his age.
It ordered him to be transferred to an "institution for mentally troubled offenders".
The court had found that the teenager could be held criminally responsible for his actions, even though two expert witnesses had given contradictory opinions on this point.
The judges rejected calls by both prosecutors and the defence to seek a third opinion.