The ex-student, identified as Nikolas Cruz, 19, walked into the Marjory Stoneman Douglas High School in Parkland on Wednesday and opened fire on students and teachers, Broward County Sheriff Scott Israel said. Police believe he acted alone.
Cruz was being held on 17 counts of premeditated murder, according to the Broward County Sheriff's website.
Cruz was armed with an AR-15-style rifle and had multiple ammunition magazines when he surrendered to officers in a nearby residential area, police said. He loved guns and was expelled for unspecified disciplinary reasons, police and former classmates said.
The shooting in a community about 45 miles (72 km) north of Miami was the 18th in a U.S. school this year, according to gun control group Everytown for Gun Safety, continuing a troubling pattern that has played out over the past few years.
It was the second deadliest shooting in a U.S. public elementary or high school after the 2012 massacre of 20 first-graders and six educators at Sandy Hook Elementary in Newtown, Connecticut.
The deadliest school shooting in U.S. history was at Virginia Tech in 2007, when 32 people were killed.
The Florida shootings stirred the long-simmering U.S. debate on the right to bear arms, which are protected by the Second Amendment of the U.S. Constitution.
Schools across the country have installed electronically secured doors and added security staff, but few legislative solutions have emerged.
"So many signs that the Florida shooter was mentally disturbed, even expelled from school for bad and erratic behavior," U.S. President Donald Trump said on Twitter on Thursday. "Neighbors and classmates knew he was a big problem. Must always report such instances to authorities, again and again!"
A law enforcement officer is assigned to every school in the Broward County district, Marjory Stoneman Douglas High board member Donna Korn told a local newspaper. The sheriff's office also provides active shooter training and schools have a single point of entry, she said.
"We have prepared the campuses, but sometimes people still find a way to let these horrific things happen," Korn said.
'The worst in humanity'
Parents raced to the school of 3,300 students and a nearby hotel that was set up as a checkpoint to find their children.
The assailant wore a gas mask as he stalked into the school carrying a rifle, ammunition cartridges and smoke grenades, then pulled a fire alarm, prompting students and staff to pour from classrooms into hallways, according to Florida's two U.S. senators, who were brief by federal authorities.
Cruz had recently moved in with another family after his mother's death in November, according to Jim Lewis, a lawyer representing the family and local media, bringing his AR-15 along with his other belongings.
The family believed Cruz was depressed, but attributed that to his mother's death, not mental illness.
"They didn't see any danger. They didn't see any kind of predilection this was going to happen," Lewis told CNN.
A chilling cell phone video broadcast by CBS News showed what it said was the shooting in progress from inside a classroom. Several students were huddled or lying on the floor surrounded by mostly empty desks. A rapid series of loud gunshots are heard along with hysterical screaming.
Colton Haab, a 17-year-old junior and member of the Junior Reserve Officer Training Corps at the high school, said he realized the alarms were not a drill after hearing several shots fired and learning that three people had been shot.
"That for me changed it to an active shooter scenario," he said. Haab rushed to his ROTC room and helped usher several dozen students inside, barricading them behind curtains made of Kevlar, a material used to make bullet-proof vests.
"We grabbed two pieces of two-by-four, a fire extinguisher and a chair," Haab said. "If he was going to try to come in the room we were going to try to stop him with whatever we had."
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)