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

MILWAUKEE — One of two Wisconsin girls charged with repeatedly stabbing a classmate to impress the fictitious horror character Slender Man pleaded guilty Monday, but she still faces a trial in the case next month focused on her mental health.

Anissa Weier, 15, pleaded guilty to attempted second-degree homicide as a party to a crime, with use of a deadly weapon. She initially faced a charge of attempted first-degree intentional homicide in the 2014 attack on Payton Leutner in park in Waukesha, a city west of Milwaukee.

Weier spoke at length during the hearing, telling Waukesha County Circuit Judge Michael O. Bohren that she understood her plea and its ramifications. She also explained her motivation for participating in her classmate's stabbing.

"I believed that if I didn't go through with it, Slender Man would come and attack and kill myself, my friends and my family. Those I cared about the most," she said.

The plea means her trial next month will look only at whether she is legally responsible for the crime or not guilty because of mental illness. She could face 10 years in prison if she's found guilty. If not, she'll spend three years in a mental hospital.

Related: Appeals Court Rules ‘Slender Man’ Stabbing Suspects Can Be Tried as Adults

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

Prosecutors allege she and her co-defendant, Morgan Geyser, stabbed Leutner 19 times in a wooded area following a sleepover, then left her. The girls planned to walk hundreds of miles north to meet Slender Man in a forest. Both suspects were 12 at the time of the attack.

Leutner was able to crawl out of the woods in the park to a path where she was found by a bicyclist.

Bohren questioned Weier about the attack. He asked her to describe what happened to ensure she understood her guilty plea.

Morgan E. Geyser is escorted into a Waukesha County Court on Nov. 11,2016, in Waukesha, Wisconsin. Michael Sears / Milwaukee Journal-Sentinel pool via AP

Weier told the judge she didn't want to harm Leutner. She said she told Geyser she couldn't stab her.

"I told her that I couldn't do it," Weier said, adding that her co-defendant "asked me whether or not she should do it" when they were in the woods.

"And I just wanted it to be over with so I said, 'Go do what you have to do,' and Peyton was then hurt," Weier said.

"How was she hurt?" the judge asked.

"Morgan (Geyser) jumped on top of her and stabbed her repeatedly," Weier said.

Geyser also was due in court Monday for a status hearing. She has pleaded not guilty by reason of mental disease to attempted homicide charges in adult court. Weier initially entered the same plea.

Related: ‘Slender Man’ Stabbing Suspects Blamed Each Other in Interrogations

Geyser's attorney, Anthony Cotton, said Monday that he and his client plan to proceed to trial. He declined comment on Weier's plea, saying it would be inappropriate to do so.

In this May 31, 2014 file photo rescue workers take 12-year-old stabbing victim Payton Leutner to an ambulance in Waukesha, Wis. AP

Cotton said he and his team have been holding mock trials weekly.

"We have continued to gather crucial information from the focus groups we've been convening repeatedly," he said, adding that they "are confident in our approach."

Slender Man started with an online post in 2009, as a mysterious specter photo-shopped into everyday images of children at play. He is typically depicted as a spidery figure in a black suit with a featureless white face. He was regarded by his devotees as alternately a sinister force and an avenging angel.

The Wisconsin case is the subject of the HBO documentary, "Beware the Slenderman." The film examines how children can become easily drawn into beliefs spread through the Internet.