Video footage has captured Florida shooting suspect Nikolas Cruz arriving at a local jail, having been charged with 17 counts of murder.

The 19-year-old was booked into Broward County jail in the early hours and was due to appear in court later in the day where he will come before a judge. When he arrived at the jail in Fort Lauderdale, Mr Cruz was still wearing a hospital gown, having been treated in a local hospital for “laboured breathing”.

Officials said the AR-15 semi-automatic weapon that Mr Cruz is said to have used in the attack was purchased legally. “No laws were violated in the procurement of this weapon,” said Peter  Forcelli, a Miami special agent with the Bureau of Alcohol, Tobacco, Firearms and Explosives.

The teenager had been expelled from Marjory Stoneman Douglas High School in Parkland a year ago and was attending another local school. Reports said that on Wednesday afternoon, he walked towards the school and starting firing outside before entering the building and continuing to fire at students and teachers as they ran for cover.

Mr Cruz was expected to appear in court on Thursday afternoon for a bond hearing, faced with 17 counts of premeditated murder, Constance Simmons, a spokeswoman for the state attorney’s office, told Reuters.

The incident on Wednesday was the second-deadliest shooting in a US public elementary or high school after the 2012 massacre of 20 first-graders and six teachers at Sandy Hook Elementary in Newtown, Connecticut. The deadliest school shooting in US history was at Virginia Tech college in 2007, when 32 people were killed.

“This has been a day we’ve seen the worst in humanity,” Broward County Public Schools Superintendent Robert Runcie told reporters.

Mr Cruz is said to have worn a gas mask as he stalked into the school carrying a rifle, ammunition cartridges and smoke grenades, then pulled a fire alarm, prompting students and staff to pour from classrooms into hallways, according to Florida’s two US senators, who were briefed by federal authorities.

Mr Cruz had recently moved in with another family after his mother’s death in November, according to Jim Lewis, a lawyer representing the family. He took his AR-15 with him.

The family believed Cruz was depressed, but attributed that to his mother’s death, not mental illness.

“They didn’t see any danger. They didn’t see any kind of predilection this was going to happen,” Mr Lewis told CNN.

Yet Mr Cruz may have left warning signs on social media. Buzzfeed reported that a person named Nikolas Cruz left a comment under a YouTube video that read: “I’m going to be a professional school shooter.“ The man who posted the video was alarmed and contacted the FBI, Buzzfeed said