Broward County Sheriff Scott Israel identified the gunman as Nikolas Cruz, 19, a former student at Marjory Stoneman Douglas High School in Parkland who had been expelled for “disciplinary reasons”.
Cruz was arrested without incident in the nearby town of Coral Springs after the Valentine’s Day rampage and taken to hospital with minor injuries, the sheriff said.
“We have already begun to dissect his websites and things on social media that he was on and some of the things... are very, very disturbing,” Israel said.
“He had countless magazines, multiple magazines, and at this point, we believe he had one AR-15 rifle,” the sheriff added.
Israel said he was uncertain about the exact number of people injured, but at least 14 were taken to hospital and two had died there of their wounds.
The shooting, one of nearly 20 since the start of the year, will once again throw the spotlight on the epidemic of gun violence in the United States and the ready accessibility of weapons in a country with 33,000 gun-related deaths annually.
“This is a terrible day for Parkland,” Israel said, speaking of the city of about 30,000 people, located 80 kilometres north of Miami.
“My very own triplets went to that school.”
A teacher at the school told the Miami Herald that Cruz had been identified previously as a potential threat to his classmates.
“We were told last year that he wasn’t allowed on campus with a backpack on him,” maths teacher Jim Gard said. “There were problems with him last year threatening students, and I guess he was asked to leave campus.”
A law enforcement source told CBS News that the gunman pulled a fire alarm before opening fire, but Israel said he could not confirm that report.
Parkland Mayor Christine Hunschofsky told CNN she had spoken to a number of students after the shooting erupted shortly after 2:00 pm (2am Thai time).
“They were very scared,” she said. “And almost in shock when they came out.”
Asked about security, the Parkland mayor said a police officer is always stationed at the school and there was a “single point of entry”.
Television images showed students, some with their hands in the air, being led out of the school by heavily armed police officers and an armoured vehicle filled with a SWAT team on the scene.
One injured victim was seen being placed into an ambulance on a stretcher.
Police officers in helmets, bulletproof vests and armed with automatic weapons could be seen stationed at several points around the sprawling school complex, which serves nearly 3,000 students.
“Just a horrible day for us,” said the superintendent of the county’s school district, Robert Runcie.
The FBI said it was assisting local law enforcement with the investigation.
Student Jeiella Dodoo told CBS News that she and her schoolmates had evacuated their classroom calmly after hearing what they thought had been a routine fire alarm.
“The alarm went off so we had to evacuate from our classes,” she said. “Then we heard gunshots.
“I heard about six gunshots,” she said, “and then some people started running and then everyone started running because we were like ‘If it’s real, then just run.’”
Teacher Melissa Falkowski told US networks that she had helped 19 students squeeze into a closet with her.
“We were in there for probably 40 minutes. We were locked in the closet until SWAT came and got us,” she told CNN.
President Donald Trump offered his “prayers and condolences” to the families of the victims.
“No child, teacher or anyone else should ever feel unsafe in an American school,” he said on Twitter.
Since January 2013, there have been at least 291 school shootings across the country – an average of about one school shooting a week, according to Everytown for Gun Safety, a non-profit group that advocates for gun control.
Since the 2012 massacre at the Sandy Hook Elementary School in Newtown, Connecticut, where 20 children and six adults were shot dead, warning procedures and emergency drills have multiplied at US schools.
The goal is to teach school children how to react to a shooter who opens fire at random.
“It is pretty clear that we’re failing our kids here,” said Falkowski, the teacher who helped shield her students from harm in a closet.
“I’m not saying the solution is one thing or another, but this does not happen in other countries the way it happens here.”