The gunman, 19, showed up at the end of the school day at his former school -- Marjory Stoneman Douglas High School in Parkland -- with a semi-automatic AR-15 assault rifle and a large amount of ammunition.
Local police later arrested him in nearby Coral Springs.
Born in September 1998, Nikolas Cruz had posted "very disturbing" messages on social media, according to Broward County Sheriff Scott Israel, who did not specify their exact content.
Authorities have not released a photograph of the shooter, and an Instagram account reportedly belonging to him has been suspended.
Cruz was known at school as having problems, according to several witnesses interviewed by local media.
"There were problems with him last year threatening students, and I guess he was asked to leave campus," Jim Gard, a math teacher who had taught Cruz for a semester in 2016, told the Miami Herald.
Gard told CNN that although he had not had problems with Cruz in class, female students reported Cruz having "problems with other girls."
Meanwhile a student, who wasn't named, told local broadcaster WSVN-7 that Cruz was "a troubled kid" who had firearms at home and had talked about using them.
"He shot guns because he felt it gave him, I guess, an exhilarating feeling," the student said.
According to another pupil, Nicholas Coke, Cruz was a "loner" who left the school and moved to northern Florida following the death of his mother. He had also undertaken a junior military training program, according to Pentagon sources who did not offer details.
The shooter had already had "a lot of problems," Coke said, recalling an incident during middle school when Cruz kicked out a window.
Meanwhile another student, speaking to local channel WJXT, said "everyone predicted" Cruz would carry out such an atrocity.
"Honestly, a lot of people were saying it was gonna be him," the pupil said.
He added Cruz knew the layout of the school and had some knowledge of security procedures through participating in fire drills.
"He knows the school layout, he knows where everyone would be at as of right now,” the student said.
"He's been with us in fire drills, he's prepared for this stuff."