Image copyright Police Photo Image caption Morgan Geyser (L) and Anissa Weier (R) were 12 at the time of the crime

A teenager involved in an attempted murder to honour an online horror character has been sentenced to 40 years in a mental hospital.

Morgan Geyser, along with Anissa Weier, lured the victim into the woods and stabbed her 19 times.

The victim was found crawling away by a cyclist but she survived the attack. All three were 12 at the time.

Weier was sentenced to 25 years in an institution in December.

Both girls admitted their part in the crime as part of a plea deal, which took into account their mental health.

Geyser's lawyers said she suffers from schizophrenia and psychotic spectrum disorder, which make her prone to delusions.

She had previously told psychiatrists she could communicate telepathically with other fictional characters, including Harry Potter and Teenage Mutant Ninja Turtles.

Investigators said Geyser stabbed the victim, while Weier urged her on.

The girls said they committed their crime in dedication to Slender Man, a fictional horror character, who told them to do it.

The judge gave Geyser the full sentence prosecutors sought, arguing she remains a risk to herself and others.

Geyser, now 15, broke down in court on Thursday while apologising to the victim and her family.

"I never meant this to happen. And I hope that she's doing well," she said.

Doctors at the sentencing hearing gave conflicting opinions on the severity of Geyster's current mental health and the treatment she needs.

Members of her defence team sought to have her moved to an adolescent health facility, but Judge Michael Bohren discounted her youth in the sentencing.

"What we can't forget is this was an attempted murder," Mr Bohren said.

Who is Slender Man?

Image copyright mdl70/Flickr

The long-limbed shadowy figure has been featured in altered photographs, drawings and videos on the internet since first appearing in 2009.

He is often depicted in a dark suit with a pale blank face and sometimes has tentacles reaching from his back.

The schoolgirls involved in the attack in Wisconsin say there were inspired after reading about the character in a creepypasta - a short online story designed to shock or scare the reader.

Eric Knudsen from Florida created the character in response to a call for submissions from the online forum SomethingAwful and posted the picture of the figure behind a crowd of people.