A Wisconsin girl who admitted to participating in the stabbing of a classmate to please horror character Slender Man will avoid prison after a jury determined she was mentally ill at the time of the attack.

Key points: Weier said Slender Man could read her mind and would kill her if she talked about him

Weier said Slender Man could read her mind and would kill her if she talked about him Defence lawyers said Weier's unhappiness stemmed from her parents' divorce

Defence lawyers said Weier's unhappiness stemmed from her parents' divorce A plea agreement called for her to spend at least three years in a mental hospital if judged mentally ill

Anissa Weier and Morgan Geyser lured classmate Payton Leutner into the woods at a park in Waukesha, a Milwaukee suburb, in 2014.

Geyser stabbed Leutner 19 times while Weier urged her on, according to investigators.

A passing bicyclist found Leutner, who barely survived her wounds.

All three girls were 12 at the time.

Both Weier and Geyser told detectives they felt they had to kill Ms Leutner to become Slender Man's "proxies", or servants, and protect their families from the demon's wrath.

Weier, now 15, pleaded guilty to attempted second-degree intentional homicide in a deal with prosecutors in August.

But she claimed she was mentally ill during the attack and not responsible for her actions, in a bid to be sent to a mental institution rather than prison.

A plea agreement called for her to spend at least three years in a mental hospital if judged mentally ill, and 10 years in prison if not.

Fictional character Slender Man lurks near forests and absorbs, kills or carries off his victims. ( theslenderman.wikia.com )

Weier's defence lawyer Maura McMahon said she hoped the case would demonstrate that children may be dealing with mental health issues lost on adults who have become too busy with their own lives to pay attention.

"Life is better for children when adults around them are in communication with each other," she said.

Judge Michael Bohren ordered a pre-commitment investigation report on Weier and said he would hold a hearing to decide how long to commit her after the report was completed.

He could sentence her more severely than the plea agreement calls for, including up to a 25-year commitment, the same as the maximum prison time she could have received.

Parents' divorce caused Weier's depression, lawyer says

In closing arguments, Ms McMahon told the jury that Weier was lonely and depressed, and descended into a "madness" that warranted a mental hospital rather than prison.

Ms McMahon said Weier's unhappiness stemmed from her parents' divorce, and she latched onto Geyser.

Together they became obsessed with Slender Man, developing a condition called shared delusional disorder, Ms McMahon said.

Weier believed Slender Man could read her mind as well as teleport and would kill her or her family if she talked about him, she said.

Slender Man, a fictional creature of the internet, is a paranormal being who lurks near forests and absorbs, kills or carries off his victims.

Geyser has pleaded not guilty to one count of attempted first-degree intentional homicide by reason of mental disease or defect, with her trial set to begin on October 9.

AP