Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

MADISON, Wis. — A Wisconsin girl who told investigators she helped stab a classmate was convinced the crime would protect her and her family from a horror character called Slender Man who she thought was real, her attorney told jurors Tuesday.

The defense is trying to convince jurors that Anissa Weier was suffering from a mental illness at the time of the stabbing at a Waukesha park in 2014 and therefore is not criminally responsible.

Anissa Weier, left, talks to her attorney Maura McMahon during jury selection in the trial to determine 15-year-old Weier's competency at Waukesha County Courthouse Monday in Waukesha, Wis. Morry Gash / AP

Payton Leutner was stabbed 19 times in a plot by Weier and co-defendant Morgan Geyser and left in a wooded park where she eventually crawled for help after the girls left, according to prosecutors. A passing bicyclist found Leutner. Weier and Geyser were arrested later that day and said they were walking to meet Slender Man in a northern Wisconsin forest. All three girls were 12 years old at the time.

"Anissa's broken mind caused her to lose touch with reality," defense attorney Joseph Smith told jurors. "Anissa was under the command and control of a delusional disorder."

During his opening statements, Smith played portions of a police interrogation of Weier shortly after her arrest in which she described a plot to kill Leutner in order to become a proxy of Slender Man, whom she described as tall and faceless with numerous tentacles capable of killing her family in a matter of seconds.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Weier, now 15, sat nearby while the snippets of the interview were played on a large screen for jurors.

Smith described Weier as a loner who struggled to fit in with her peers and who found a friend in Geyser. While Weier was dealing with her parents' divorce, teachers began noticing symptoms of depression, he said. With Geyser, Weier developed a "delusional belief system" and together they made a plan to kill Leutner and become Slender Man's proxies, Smith said. Although Weier did not physically stab Leutner, in her mind she knew it had to be done, Smith told jurors.

Waukesha County Assistant District Attorney Kevin Osborne told jurors that Weier may have believed Slender Man was real, but she had the mental capacity to know she was committing a crime. Osborne says the initial plan was for Weier to stab Leutner, but Weier couldn't do it and instead directed Geyser to do the stabbing.

Morgan E. Geyser is escorted into a Waukesha County Court, Friday, Nov. 11,2016, in Waukesha, Wis. Michael Sears / AP

"They knew this was wrong. They understood what they were doing was wrong," Osborne said.

Osborne said the police interviews show Weier did not know she or her family could be in danger until Geyser told her after the attack had taken place.

"She goes along because she wants to preserve the one and only friendship" with Geyser, he said.

Both Weier and Geyser were charged with being a party to attempted first-degree intentional homicide. Weier struck a deal with prosecutors in August in which she pleaded guilty to being a party to attempted second-degree intentional homicide, essentially acknowledging she committed all the elements of the offense. But she also pleaded not guilty due to mental illness of defect, setting up the trial on her mental status.

Judge Michael Bohren told jurors they must decide whether Weier had a mental illness at the time of the crime and if so, whether she lacked the capacity to understand her wrongful conduct.

Psychologists testified at a previous court hearing that Weier suffered from persistent depression and a delusional disorder linked to schizotypy, a diminished ability to separate reality from fantasy.

At least 10 of the 12 jurors must agree on a verdict.

Geyser has pleaded not guilty to being a party to first-degree attempted homicide. Her trial is set to begin Oct. 9.