The gunman who allegedly killed at least 17 people at a Florida high school on Wednesday was a former student who posted disturbing material on social media and was "crazy about guns".

Police identified the suspect as Nikolas Cruz, a 19-year-old who had been expelled from Marjory Stoneman Douglas High School in Parkland, about 45 miles (72 km) north of Miami.

The suspect was wearing a gas mask and carrying smoke grenades, Sen. Bill Nelson of Florida told CNN.

Mr Nelson, who said he had been briefed by the FBI, said the attacker "set off the fire alarm so the kids would come pouring out of the classrooms into the hall. And there the carnage began."

He said he did not know if the gunman had used the smoke grenades but he assumed that's why he had a gas mask on.

Frightened students ran out onto the streets as shots rang out before SWAT team members swarmed the building.