WAUKESHA, Wis. — One of two Wisconsin girls who tried to kill a classmate to win favor with a fictional horror character named Slender Man was sentenced Thursday to 25 years in a mental hospital, the maximum punishment possible.

Anissa Weier, 16, pleaded guilty in August to being a party to attempted second-degree intentional homicide, but she claimed she wasn't responsible for her actions because she was mentally ill. In September, a jury agreed.

In this Sept. 14, 2017, photo Anissa Weier listens as her attorney Maura McMahon questions a witness in Waukesha County Court in Wisconsin. Michael Sears / Pool/Milwaukee Journal-Sentinel via AP

Waukesha County Circuit Judge Michael Bohren on Thursday sentenced Weier to 25 years in a psychiatric institution, retroactive to the date of the crime. That means she would be institutionalized until age 37.

Weier and Morgan Geyser lured Payton Leutner into a wooded park in Waukesha, a Milwaukee suburb, in 2014. Geyser stabbed Leutner 19 times while Weier urged her on, according to investigators. Leutner survived after she crawled out of the woods to a path where a passing bicyclist found her.

Both Weier and Geyser told detectives they felt they had to kill Leutner to become Slender Man's "proxies," or servants, and protect their families from him. All three girls were 12 years old at the time.

Weier apologized in brief comments before her sentencing.

"I do hold myself accountable for this and that I will do whatever I have to do to make sure I don't get any sort of delusion or whatever again," Weier told the judge, as she sat next to her attorney. "I want everybody involved to know I deeply regret everything that happened that day. I know that nothing I say is going to make this right and nothing I say is going to fix what I broke."

Leutner's mother, Stacie Leutner, sent the judge a letter this week in which she wrote that the trauma of the attack "has defined our lives" and that her daughter still fears for her life. For months, Payton slept with scissors under her pillow for protection, and she still keeps her bedroom windows closed and locked.

"She will struggle with the events of that day and physical and emotional scars it left for the rest of her life," her mother wrote.

Related from 2014: Stabbing victim released from hospital, said 'I wanted to live'

In her letter, Leutner did not ask the judge to sentence Weier to a specific length of time in the mental hospital, but she said her daughter wouldn't feel safe if either of her attackers is released back into the community unsupervised.

"Payton has a lifetime of healing ahead of her and she deserves to be allowed to heal in an environment where she feels safe," her mother wrote.

Morgan Geyser enters a Waukesha County Court for a status hearing on Sept. 29, 2017, in Waukesha, Wisconsin. Michael Sears / Milwaukee Journal-Sentinel via AP, Pool

No one from the victim's family addressed the court during the sentencing hearing, deferring instead to the letter from her mother. Prosecutor Kevin Osborne argued for the maximum 25-year confinement, which the judge granted citing ongoing concerns about her mental stability.

"Considering the nature and gravity of this offense, being supervised until the age of 37 is not all that long ... in terms of the fact that Payton is looking at a lifetime of scars, physical scars and psychological scarring," Osborne said.

Weier's attorney, Maura McMahon, argued that she should not be hospitalized beyond her 25th birthday. She played a video in court with Weier's father, sister and grandparents speaking on her behalf.

"She's grown mentally and physically," her father William Weier said. "She knows what she did was wrong."

He asked for forgiveness from the Leutner family.

In a deal with prosecutors, Geyser, who did the stabbing, pleaded guilty to first-degree intentional homicide with the agreement that she isn't criminally responsible and shouldn't go to prison. She will be sentenced in February, and prosecutors have asked that she be given at least 40 years in a mental hospital.

Slender Man started with an online post in 2009, as a mysterious specter whose image people edit into everyday scenes 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.