CHICAGO - One of two US girls who pleaded guilty to stabbing their friend to appease a fictional internet character, was sentenced to 40 years in a mental hospital on Thursday.

Morgan Geyser and her friend Anissa Weier were both 12-years-old when they stabbed classmate Payton Leutner 19 times in 2014 in a woodland area near their home in a suburb of Milwaukee. Leutner survived the attack.

Geyser and Weier, both now 15, said they believed a sinister fictitious internet character known as "Slender Man" was real and demanded they commit the murder or their own families would be harmed.

A judge sentenced Geyser to 40 years in a restrictive adult mental health facility, as opposed to the lesser 25 years her attorney was seeking at a juvenile facility where she would have been eligible for supervised release if she was considered well enough.

"I'm sorry. I never meant this to happen. I hope that she's doing well," a tearful Geyser said in court prior to sentencing.

Both Weier and Geyser were found not responsible for their crime due to mental illness.

Their case inspired the 2016 documentary "Beware the Slenderman," which featured video of the girls' interrogations in which they admitted to stabbing Leutner.

Weier was sentenced in December to 25 years in a mental institution - a shorter period than Geyser because she had reached a plea agreement on a lesser charge.

Geyser is still eligible to petition for supervised release every six months, but would have to appear before a judge who would decide on her mental fitness.