In this Oct. 6, 2021, file photo, Parkland school shooter Nikolas Cruz looks up after crying during day two of jury selection in his trial at the Broward County Courthouse in Fort Lauderdale Florida. Credit: Amy Beth Bennett / South Florida Sun Sentinel via AP

FORT LAUDERDALE, Florida — The gunman who killed 14 students and three staff members at a Parkland, Florida, high school will plead guilty to their murders, his attorneys said Friday, bringing some closure to a South Florida community more than three years after an attack that sparked a nationwide movement for gun control.

The guilty plea would set up a penalty phase where Nikolas Cruz, 23, would be fighting against the death penalty and hoping for life without parole.

Attorneys for Cruz told Circuit Judge Elizabeth Scherer that he will plead guilty Wednesday to 17 counts of first-degree murder in the February 2018 shooting at Marjory Stoneman Douglas High School. The pleas will come with no conditions and prosecutors still plan to seek the death penalty. That will be decided by a jury, with the judge hoping to start the trial in January.

Cruz will also plead guilty to 17 counts of attempted first-degree murder. He was not initially present during the hearing, but later entered the Broward County courtroom to plead guilty to attacking a jail guard nine months after the shooting.

The trial has been delayed by the pandemic and arguments between the prosecution and defense over what evidence and testimony could be presented to the jury. Some victims’ families had expressed frustration over the delays, but the president of the group they formed expressed relief that the case now seems closer to resolution.

Attorney Alex Arreaza represents Anthony Borges, a Parkland student who was 15 when he was gravely wounded during the shooting. Arreaza said the news of the guilty pleas was an unexpected development that brings the family some relief.

“It all came down as a surprise to us,” Arreaza said. “Anthony and his family are glad this is finally coming to an end, and he can move on.”

Andrew Pollack, whose 18-year-old daughter Meadow was killed, said the only thing that’s really changed is that Cruz is now closer to being sentenced.

“He’ll either get death, or life in prison,” Pollack said, adding that he’s more focused on the systemic failures in the school system that led to the shooting. “Death by lethal injection seems too peaceful to me. I’d rather see a hanging in a public square.”

In the aftermath of the shooting, Parkland student activists formed March for Our Lives, a group that rallied hundreds of thousands around the country for tighter gun laws, including a nationally televised march in Washington, D.C. Parents also made impassioned pleas for accountability and policies aimed at halting gun violence.

The decision by Cruz and his attorneys to plead guilty came unexpectedly. Preparations were being made to begin jury selection within the next few months. He had been set to go on trial next week for the attack on the Broward County Jail guard.

Cruz and his lawyers had long offered to plead guilty in exchange for a life sentence, but prosecutors had repeatedly rejected that deal, saying the case deserved a death sentence.

Cruz’s rampage crushed the veneer of safety in Parkland, an upper-middle-class community outside Fort Lauderdale with little crime. Its educational crown jewel is Stoneman Douglas, a campus of 3,200 students that is one of the top-ranked public schools in the state.

Cruz was a longtime, but troubled resident. Broward sheriff’s deputies were frequently called to the home in an upscale neighborhood he shared with his widowed mother and younger brother for disturbances, but they said nothing was ever reported that could have led to his arrest. A state commission that investigated the shooting agreed.

Cruz alternated between traditional schools and those for troubled students.

He attended Stoneman Douglas starting in 10th grade, but his troubles remained — at one point, he was prohibited from carrying a backpack to make sure he didn’t carry a weapon. Still, he was allowed to participate on the school’s rifle team.

He was expelled about a year before the attack after numerous incidents of unusual behavior and at least one fight. He began posting videos online in which he threatened to commit violence, including at the school. It was about this time he purchased the AR-15 semiautomatic rifle he would use in the shooting.

When Cruz’s mother died of pneumonia in 2017, four months before the shooting, he began staying with friends, taking his 10 guns with him.

Someone, worried about his emotional state, called the FBI a month before the shooting to warn agents he might kill people. The information was never forwarded to the agency’s South Florida office and Cruz was never investigated or contacted.

Another acquaintance called the Broward Sheriff’s Office with a similar warning, but when the deputy learned Cruz was then living with a family friend in neighboring Palm Beach County he told the caller to contact that sheriff’s office.

In the weeks before the shooting, Cruz began making videos proclaiming he was going to be the “next school shooter of 2018.”

The shooting happened on Valentine’s Day, minutes before the end of the school day. Students had exchanged gifts and many were dressed in red.

Cruz, then 19, arrived at the campus that afternoon in an Uber, assembled his rifle in a bathroom and then opened fire on students and staff members, the smoke from his rifle setting off the fire alarm.

Outside the building, sheriff’s deputy Scot Peterson, the school’s longtime resource officer, heard the shots but did not enter the building — he drew his gun and hid behind a column and wall, video shows. He told investigators he did not know where the shots were coming from, but they said his radio transmissions show he did.

Peterson has been charged with felony child neglect for allegedly failing to protect the students and perjury for allegedly lying to investigators. He has pleaded not guilty.

Cruz eventually dropped his rifle and fled, blending in with his victims as police officers arrived and stormed the building. He was captured about an hour later walking through a residential neighborhood. Later that night, he confessed to detectives.

The shooting led to a state law that requires all Florida public schools to have an armed guard on campus during class hours.

Story by Terry Spencer. Associated Press writers Freida Frisaro and Curt Anderson contributed to this report.