BOISE, Idaho (AP) — A criminal justice student who avoided a potential death sentence by pleading guilty Wednesday to the brutal stabbing deaths of four University of Idaho students carefully planned the attack for months and took multiple steps to cover his tracks, the lead prosecutor said.

Bryan Kohberger, who was a graduate student at nearby Washington State University, pleaded guilty to murder in the killings that terrified the Idaho campus and set off a nationwide search, which ended weeks later when he was arrested in Pennsylvania.

Kohberger remained impassive as he admitted to breaking into a rental home through a kitchen sliding door and killing the four friends who appeared to have no connection with him. Prosecutors did not reveal a motive behind the slayings.

The killings initially baffled law enforcement and unnerved the rural college town of Moscow, which hadn’t seen a murder in five years until Kaylee Goncalves, Ethan Chapin, Xana Kernodle and Madison Mogen were found dead near campus on Nov. 13, 2022. Autopsies showed each was stabbed multiple times.

In the two years since Kohberger’s arrest, his attorneys unsuccessfully attempted to bar prosecutors from seeking the death penalty and challenged DNA evidence, leaving a plea deal their final alternative to spare his life before the start of a trial in August.

At least one of the families opposed the plea deal that calls for Kohberger to serve four life sentences and removes his ability to appeal. But others supported the agreement, saying they were ready to begin healing.

The plea hearing provided a few new details about the killings but key questions remained, including why Kohberger spared two other roommates.

After breaking into the home, he climbed to the third floor where he first killed Mogen and Goncalves together, Latah County Prosecuting Attorney Bill Thompson said Wednesday.

He then ran into Kernodle, who was still awake after getting a Door Dash order, and stabbed her and her boyfriend, Chapin, who was still asleep, Thompson said. There were no signs of sexual assault, he said.

Police have said they used genetic genealogy to identify Kohberger as a possible suspect and accessed cellphone data to pinpoint his movements the night of the killings.

At the time, Kohberger had just completed his first semester at Washington State and was a teaching assistant in the criminology program.

Kohberger was arrested in Pennsylvania, where his parents lived, weeks later. Thompson said investigators recovered a Q-tip from the garbage at his parents’ house to match Kohberger’s DNA to genetic material from a knife sheath found at the crime scene.

Although the Goncalves family opposed the agreement and sought to stop it, they also argued that any deal should have required Kohberger to make a full confession, detail the facts of what happened and provide the location of the murder weapon.

“We deserve to know when the beginning of the end was,” they wrote in a Facebook post.

Kaylee Goncalves’ father, Steve Goncalves, left the courthouse before Kohberger entered the courtroom. “I’m just getting out of this zoo,” he told reporters.