The suspect was identified as Nikolaus Cruz, a former student who had been expelled from Marjory Stoneman Douglas High School in Parkland for disciplinary reasons, Broward County Sheriff Scott Israel said.
He said at least 14 other people were injured in addition to the 17 people killed.
Officials believe the gunman had one AR-15-style semiautomatic rifle, but it was unclear whether he had any other weapons. The gunfire began outside the school and continued inside, where 12 of the victims were killed, Israel said.
Cruz was taken into custody off campus about an hour after he “committed this horrific, detestable act,” Israel said. Federal and local authorities told NBC News there was no indication that he had an accomplice or accomplices.
Parkland, in north Broward County, is about 30 miles northwest of Fort Lauderdale. The shooting on the sprawling campus happened despite the presence of police officers at the school.