The violence erupted shortly before dismissal at Marjory Stoneman Douglas High School in Parkland, about 45 miles (72 km) north of Miami. Live television footage showed students streaming out of the building as dozens of police and emergency services personnel swarmed the area.
The gunman was identified as Nikolas Cruz, who previously attended the school and was expelled for unspecified disciplinary reasons, Broward County Sheriff Scott Israel said at a news briefing hours later.
“It’s a horrific situation,” Broward Country Schools Superintendent Robert Runcie told reporters separately.
The gunman surrendered to police without a struggle, Israel said.
Students hid in classrooms until they were rescued by police in tactical gear, friends and family members said.
McKenzie Hartley, who identified herself as the sister of a student at the school described the scene in a text message to Reuters: “She heard him shooting through the windows of classrooms and two students were shot.”
Panicked parents checked on their children.
“My daughter, as of right now, she’s still trapped in a closet. She’s afraid to speak,” a man who identified himself as Caesar Figueroa and said his daughter was inside the school, told CBS News.
“I told her, ‘Don’t call me, because I don’t want no one to hear your voice.’ So, she’s still trapped in a closet in there.”
Live television showed dozens of students, weaving their way between law enforcement officers with heavy weapons and helmets, and large numbers of emergency vehicles including police cars, ambulances and fire trucks.
Florida Governor Rick Scott said on Twitter that had he had been in touch with local officials about the incident.
It was the 18th shooting in a U.S. school so far this year, according to gun control group Everytown for Gun Safety. That tally includes suicides and incidents when no one was injured, as well as the January incident when a 15-year-old gunman killed two students at a Benton, Kentucky, high school.
More than five years have passed since a gunman killed 20 first graders and six educators in Newtown, Connecticut, stirring the long US debate about gun rights, which are protected by the Second Amendment of the U.S. Constitution.
“My prayers and condolences to the families of the victims of the terrible Florida shooting,” U.S. President Donald Trump said on Twitter. “No child, teacher or anyone else should ever feel unsafe in an American school.”