 -- A Wisconsin judge has sentenced the second of two teenage girls accused of the 2014 attempted homicide of their friend by stabbing her in the woods to please the fictional character Slender Man.

Morgan Geyser, 15, was sentenced to 40 years under a mental health institution's supervision. While she may periodically petition for release from the hospital in the future, she will be under institutional supervision for that time.

“I just want to let Bella and her family know that I’m sorry,” Geyser told the court after arguments, breaking into tears. “I never meant this to happen. I hope that she’s doing well.”

Bella is the nickname Geyser had given the victim, Payton Leutner, when they were younger.

Watch the full story on "20/20" FRIDAY, Feb. 2 at 10 p.m. ET

Geyser and Anissa Weier were arrested May 31, 2014, after attacking Leutner with a knife and leaving her behind in the Waukesha woods. All three girls were 12 years old at the time.

Leutner was stabbed 19 times, but able to crawl to a nearby road where a passing bicyclist stopped to help her. Now 15, she survived her life-threatening injuries.

Prosecutors have said that both Geyser and Weier were obsessed with Slender Man, a character often depicted in fan fiction online as a horror figure who stalks children.

3:28

During the sentencing hearing, both prosecutors and Geyser’s defense attorneys called on mental health professionals who had evaluated Geyser to testify. Psychologist Dr. Brooke Lundbohm and psychiatrist Dr. Kenneth Robbins both testified that Geyser had made progress in her mental health treatment. But Lundbohm, who was court-appointed, testified that Geyser was still hearing voices near the time of her October 2017 evaluation.

“She had reported that she had last heard an auditory hallucination that she calls ‘Maggie’ just a few weeks before our contact,” Lundbohm said.

Geyser’s attorneys also called on Jessie Andrews, the director of forensic services at Winnebago Mental Health Institute where Geyser now lives. Andrews testified that Geyser “does not present with psychotic symptoms at this time.” Geyser, according to Andrews, has been held with adults at Winnebago Mental Health Institute because her case was in adult court. She is the youngest patient in her living unit.

“I would estimate it was August or September 2017 when [Geyser’s] psychotic symptoms were gone,” Andrews said.

When asked, court-appointed psychologist Dr. Kent Berney concurred with a report he submitted that he believed Geyser “is appropriate for consideration for a less-restrictive setting than in-patient psychiatric care” and that residential treatment would be “optimal.”

Prosecutors asked for the maximum sentence of 40 years under institutional supervision, while Geyser’s attorneys asked for a length of time similar to Weier’s sentence.

In December 2017, Weier, now 16, was sentenced to 25 years under a mental health institution's supervision, after a jury found her not guilty by reason of mental disease or defect after she had pleaded guilty to second-degree attempted intentional homicide, party to a crime.

Geyser pleaded guilty last year to attempted first-degree intentional homicide, party to a crime. However, she agreed to a plea deal with prosecutors in which the court also found her not guilty by reason of mental disease or defect, despite her guilty plea.

1:37

"Please take into consideration everything my daughter and family has endured when deciding your sentence for Morgan," Josef Leutner, Payton Leutner's father, wrote in a victim impact statement to Judge Michael Bohren ahead of Geyser's sentencing. "Payton should not have to spend the remainder of her youth with her curtains closed, looking over her shoulder every day and praying that they will not come after her again."

Josef Leutner wrote in his statement that the incident took away many of the things his family once enjoyed doing together.

"My family used to spend a lot of time together taking road trips to hike different areas, camp, or just take our pup to the dog park," he wrote. "They have all become a distant memory for us because Payton refuses to go back in the woods and sleeping there is completely out of the question."

In the statement, Josef Leutner also wrote about the hours and days after his daughter was stabbed.

"Daily care was an immense process as she healed because she could not bend or stand up on her own," he wrote. "She spent many nights sleeping next to [her mother] Stacie so she would not have to be alone, while I slept in her bed. Between follow-up visits to the doctor, court dates, and emotional care, we have not had a chance to find a new normal. But here we are, for better or worse, we are together."

Stacie Leutner also wrote a victim's impact statement that was given to the judge before Weier’s sentencing. In it, she wrote that her family accepted the plea deals for both Weier and Geyser to keep her daughter from testifying.

"Traumatizing her further didn't seem worth it," Stacie Leutner wrote. "[Payton] has never talked about her attack so asking her to testify and relive her experience in front of a courtroom of strangers felt cruel and unnecessary."

Stacie Leutner also wrote that her daughter felt a mental health facility was best for her attackers.

1:30

Morgan Geyser's mother Angie Geyser told "20/20" she often thinks about Payton Leutner and her family.

"I'm so sorry for what Payton went through and for what they must have gone through, and I would take it back if I could," Angie Geyser said. "I hope that they can understand that it wasn't the Morgan that they knew who did this to their daughter. That Morgan was sick, she wasn't in control of her brain and I hope that maybe someday they can forgive her."

"When you send your child to another family's home, you trust that family to keep your child safe while she's there," Angie Geyser said, "and I'm sorry that we didn't."

ABC News’ Emily Whipp and Emily Shapiro contributed to this report.