A former Virginia Tech student entered a no contest plea Friday in a case that alleged he brutally stabbed a 13-year-old girl he met online, a move that abruptly ended his trial in the high-profile murder case.

David Eisenhauer, 20, entered his plea in Montgomery County Circuit Court to charges of first-degree murder, abduction and concealing a dead body in the death of Nicole Lovell, a seventh-grade student at Blacksburg Middle School he met in an anonymous chat room.

The unexpected plea came after the opening days of a trial in which prosecutors said the onetime engineering student had searched the Internet for ways to dispose of a body, that blood was found in his car and that his DNA was under Nicole’s fingernails. Nicole’s mother had taken the witness stand, tearfully recounting the January 2016 morning she realized her daughter had disappeared after slipping out her bedroom window.

The prosecution told jurors in opening statements Tuesday that Eisenhauer killed Nicole and dumped her body across the border in North Carolina because he was worried about his relationship with an underage girl.

A no contest plea means Eisenhauer, while not admitting to the crimes, would no longer fight the prosecution’s case.

Judge Robert Turk told him he faced a sentence of as much as life plus 15 years.

Prosecutors said in court Friday that, had the trial continued, they would have presented testimony of incriminating chat logs between Eisenhauer and an alleged accomplice, another former Virginia Tech student.

Nicole’s mother, Tammy Weeks, was shaking as she read remarks after the plea.

“I was blessed to be Nicole’s mother. To be her friend for 13 years. We fought every fight together but this last one,” Weeks said. She said her daughter “will always rest in our hearts, and no amount of time will ever change that.”

Eisenhauer’s plea brings “some resolution and some justice” to Nicole’s death, which shocked the Blacksburg and Virginia Tech communities, Montgomery County, Va., Commonwealth’s Attorney Mary Pettitt said at the news conference Friday. “The justice system is just incapable of healing this loss for Nicole’s family, Nicole’s friends or the community,” Pettitt said. “We all suffer with the loss of this little girl.”

Pettitt said she would not be discussing evidence and noted she still has another defendant to try in connection to the murder. Natalie Keepers, who was Eisenhauer’s friend and classmate at Virginia Tech, is charged with accessory to murder before the fact and concealing a dead body. She is scheduled to go on trial in September.

“Today there were no winners,” Blacksburg Police Department Chief Anthony Wilson said at the news conference. “If we had won, we wouldn’t be in this room, and Nicole would be in Blacksburg Middle School, where she belongs.”

In his own words, Eisenhauer told FBI Special Agent Travis Witt how he met the teen in an anonymous online chat room before the two began messaging on Kik, another messaging platform.

Eisenhauer, then 18, was an engineering major and had been a state-champion runner for ­Wilde Lake High School in Columbia, Md.

Witt was questioning Eisenhauer about the disappearance of the 13-year-old girl as a massive search was underway to find her. The interview, captured on video and played in court this week, showed Eisenhauer explaining how he thought Nicole was 16 or 17. When he arrived at her house the early morning of Jan. 27, he told Witt, he saw “someone who is maybe 11 years old climb out of a window” and thought “uh-uh, not for me.”

While Eisenhauer told Witt he then left without her, Pettitt laid out the evidence against Eisenhauer in her opening statements.

She said his DNA was found under Nicole’s fingernails, her blood was found in the trunk of his car, and Eisenhauer had done Internet searches of things like “Knock out drugs”; “How long does it take to burn a body”; and “How does the TV serial killer Dexter get rid of bodies.”

The defense had tried to shift the blame of the murder to Keepers, saying she had admitted to police her involvement in the murder with the “sole exception” of being at the scene. Defense attorney John Lichtenstein said Keepers’ involvement brought into question: “Who actually committed this murder?”

An attorney representing Keepers has declined to comment on the defense’s statements.

In court, Pettitt said the evidence pointed to Eisenhauer, telling jurors the story of a self-conscious seventh-grade girl who was excited about her “secret date.”

Instead, Eisenhauer took her into the woods and “coldly and ruthlessly” stabbed her 14 times, in the chest and throat, the prosecutor said.

Eisenhauer had also messaged Nicole not to tell anyone about him because “they will find a way to hurt you,” the prosecution said Friday. Nicole replied: “Who will hurt me? Who’s they? Why are you scaring me? Do you even want to be with me? Do you trust me? You’re scaring me. I’m going to go.”

Nicole’s family and friends, all dressed in Nicole’s favorite color blue, sat in the courtroom Tuesday and listened as her mother described the moment she realized her daughter was missing.

Holding back tears, she said the next time she saw Nicole was “in her coffin.”

In another video interview from 2016 played in court this week, Eisenhauer told Montgomery County Sheriff’s Deputy Matthew Wilburn he did not want to go to jail and did not do anything wrong. Eventually, he asked: “Do you think there’s enough evidence to convict me?”