Trystan Andrew Terrell also pleaded guilty to four counts of attempted murder and discharge of a firearm on educational property in connection with the April 30 shooting at the University of North Carolina at Charlotte. The hearing was originally intended to decide whether Terrell could face the death penalty.
Prosecutors believe Terrell, a former student at the school, spent months planning the attack. Authorities say he opened fire with a legally purchased pistol on the last day of spring semester classes. It wasn't clear if a specific student was targeted.
Terrell had been enrolled in the course but quit in January.
The shooting didn't go on as long as it might have; a student, Riley Howell, tackled Terrell, which gave responding officers enough time to capture him, authorities said.
Howell, 21, of Waynesville, and Reid Parlier, 19, of Midland, were shot multiple times and died.
Those wounded were Sean Dehart and Drew Pescaro, both of Apex; Emily Houpt of Charlotte; and Rami Alramadhan of Saihat, Saudi Arabia.
In court, family members of the victims read statements.
"We will never forgive him for his actions," Parlier's mother, Julie, said of the accused man. "If the defendant wanted to kill someone, he should have turned the gun on himself."
"May you rot in hell and suffer torture," she added.
Terrell apologized when he was given an opportunity to speak.
"I am so sorry to everyone," he said. "If I could go back in time to that classroom, I would back out of it. I made a mistake."
Spencer Merriweather III, Mecklenburg County district attorney, said the plea was the right call and will save families the anguish of having to endure a death penalty trial.
Pescaro, who was wounded in the attack, disagreed.
In a statement to WCCB-TV, he said Terrell "knew he wanted to get life in prison when planning this violent act, and the DA's office is rewarding him by giving him exactly what he wanted,"