(CNN) -- Nikolas Cruz, the gunman who carried out the massacre of students and faculty members at Marjory Stoneman Douglas High School in February 2018, pleaded guilty in a Florida courtroom Wednesday to 17 counts of murder and 17 counts of attempted murder.
Cruz, 23, faces a minimum of life in prison and maximum of the death penalty, which will be decided by a jury in the upcoming sentencing phase of the trial. The prosecution has said they plan to seek the death penalty.
In court, Cruz wore a collared shirt, black vest, face mask and large, thick-framed glasses. He stood at the court lectern and answered Judge Elizabeth Scherer's series of questions with a "yes ma'am" or "no ma'am," and assured her, "I know what's going on." He said he had depression and anxiety, and that he was experiencing anxiety in court, but he said he was able to proceed.
Cruz then responded "guilty" when each of the 34 charges were read to him. Afterward, he apologized to the victims in a short speech.
"I am very sorry for what I did, and I have to live with it every day. If I were to get a second chance, I would do everything in my power to try to help others," he said. "I am doing this for you, and I do not care if you do not believe me. And I love you, and I know you don't believe me, but I have to live with this every day, and it brings me nightmares and I can't live with myself sometimes, but I try to push through because I know that's what you guys would want me to do.
"I hate drugs, and I believe this country would do better if everyone would stop smoking marijuana and doing all these drugs and causing racism and violence out in the streets," he continued. "I'm sorry, and I can't even watch TV anymore. And I'm trying my best to maintain my composure, and I just want you to know I'm really sorry, and I hope you give me a chance to try to help others. I believe it's your decision to decide where I go, and whether I live or die. Not the jury's. I believe it's your decision. I'm sorry."
The judge then asked Cruz if he understood that a jury, and not the victims' families, would have the legal power to decide his sentence, and he confirmed that he understood.
"What I meant was I believe they should have the right to choose, the victims themselves, on whether I should take life or death," Cruz said.
He was then placed in handcuffs, fingerprinted and escorted from the courtroom.
Jury selection in the penalty phase is scheduled for January 4.
The plea comes more than three and a half years after the Valentine's Day shooting in Parkland, Florida, in which he killed 17 students and faculty members and injured 17 others in what is the deadliest high school shooting in US history.
A dozen law enforcement officers filled the courtroom Wednesday while media, victims, and the family of victims watched the proceedings, some of whom were seen wiping their eyes as the judge detailed the counts and penalties to Cruz.
The prosecution laid out the harrowing timeline of the shooting, which began when Cruz, then 19, grabbed his AR-15-style rifle and magazines and rode in an Uber to his former high school. There, he took out his rifle and loaded it, and when a student walked near, Cruz offered a warning. "You better get out of here," he told the student. "Something bad is about to happen."
Cruz then wandered through the halls of the school and fired indiscriminately at various students and staff in hallways and classrooms, prosecutors said. He eventually left the school and was taken into custody several miles away.
Change of plea was previewed last week
Cruz had previously pleaded not guilty to 17 counts of premeditated murder in the first degree and 17 counts of attempted murder in the first degree, though he had confessed to police, according to a probable cause affidavit.
The change of plea to guilty was previewed on Friday when Cruz appeared briefly in Broward County court to plead guilty to charges related to a November 2018 jail assault. At the hearing, defense attorney David Wheeler said in court that Cruz intends to plead guilty in the school shooting, which could avert part of a lengthy trial.
Cruz's defense team had long ago offered a guilty plea in exchange for life in prison without the possibility of parole -- but only if prosecutors took the death penalty off the table. Prosecutors had rejected that, saying they were seeking the death penalty.
The impact of the February 2018 shooting was felt far beyond South Florida, as survivors and victims' relatives quickly spoke out and confronted lawmakers to plead for gun control reform. Other students in the US joined the cause, staging their own protests and school walkouts in the months after the massacre.
As for the jail assault case, Cruz appeared in Scherer's courtroom Friday to plead guilty, cutting off a trial for which jury selection began earlier this month. Cruz was accused of attacking a jail guard in November 2018, authorities said.
He pleaded guilty to attempted aggravated battery on a law enforcement officer, battery on a law enforcement officer, depriving an officer of means of protection; and use of a self-defense weapon against a law enforcement officer.
Scherer on Wednesday sentenced Cruz in that case to 25 years in Florida state prison also 364 days in county jail. Cruz will be credited for the 1,345 days he has already served, the judge said.
According to the arrest report, the incident began when a jail officer asked that Cruz not drag his sandals on the ground while walking around a dayroom area.
Cruz tackled and repeatedly punched the guard, then took his stun gun in a fight, according to the arrest report. As they wrestled over the device, the weapon discharged, the report states. Cruz struck the sergeant several more times until the guard regained control of the weapon, struck at Cruz's face and took him into custody, the report states.
Cruz's guilty plea comes just after a $25 million settlement was reached between the Broward County School Board and 52 victims of the massacre, according to an attorney for some of the victims.
Attorney David Brill said the settlement of the lawsuit includes all of the families of the 17 who died, 16 of 17 victims who were shot but survived, and 19 victims who suffer from PTSD or other ailments.
™ & © 2021 Cable News Network, Inc., a WarnerMedia Company. All rights reserved.