At least 17 students at a Florida high school were killed after a gunman opened fire on them with an automatic rifle, in one of the deadliest school shootings on record in the US.

Officials said another 14 were injured at the Marjory Stoneman Douglas High School in the small city of Parkland, around 45 miles north of Miami.

The suspect has been identified as 19-year-old former student Nikolas Cruz, who was arrested after a brief manhunt. Mr Cruz had been expelled for “disciplinary reasons”, while teachers said they had previously been warned that he could pose a danger to the campus.

It was the 18th shooting of the year either in or around school premises, according to research by Everytown for Gun Safety, a non-profit group which advocates for gun control.

Just as classes were being sent home for the day, police say Mr Cruz began spraying bullets into the high school hallway. Authorities said Mr Cruz carried “countless magazines” and an AR-15 rifle.

Florida senator Bill Nelson, who claimed to have been briefed by the FBI on the issue, said the shooter wore a gas mask and carried smoke grenades.

He also said that the fire alarm had been set off so that his victims would pour out into the hall.

Florida shooting – in pictures Show all 10 1 /10 Florida shooting – in pictures Florida shooting – in pictures Police arrest a suspect in connection with the shooting at the Marjory Stoneman Douglas High School in Parkland, Florida Reuters Florida shooting – in pictures Parents wait for news after reports of a shooting at Marjory Stoneman Douglas High School in Parkland, Florida AP Florida shooting – in pictures Anxious family members wait for news of students AP Photo/Wilfredo Lee Florida shooting – in pictures Students being evacuated from the school AP Florida shooting – in pictures Students being evacuated from the school Getty Florida shooting – in pictures People gather waiting for word from students AP Florida shooting – in pictures Parents waiting for news on their children AP Florida shooting – in pictures People gather at a hotel where students were taken after the shooting Getty Florida shooting – in pictures Florida Governor Rick Scott speaks to the media as he visits Marjory Stoneman Douglas High School following the shooting AFP/Getty Florida shooting – in pictures Dr. Igor Nichiporenko, Medical Director Trauma, left, and Dr. Evan Boyer, Medical Director, Emergency Services, speak about treating victims and the suspect at a press conference outside Broward Health North hospital AP

“It’s a horrific situation,” Broward County Public Schools Superintendent Robert Runcie told reporters after the shooting. ”It is a day that you pray every day that you never have to see.”

He added: “We didn’t have any phone calls or threats that we know of that were made. We cannot live in a world built on fear, we have do what we can to provide the greatest safety measures for our kids.”

Asked if the incident was related to mental health, Mr Runcie said: “No sane person is going to go and commit such an atrocity.”

Parkland shooting: Students evacuated from school campus

Local news reported that a number of people could be seen being loaded into ambulances on a stretcher soon after the shooting.

Other students could be seen running to police safety outside of the school, where they all dumped their backpacks in a pile and were told to sit on the grass.

The school day at Stoneman Douglas typically ends at 2.40pm, and the first tweet from the Broward County Sheriff’s Department about the incident came at 2.53pm.

Broward County Sheriff Scott Israel told reporters the that authorities believe Mr Cruz killed three people outside the school, before entering the building and killing another 12. Two people later died after being taken to hospital.

“We have already begin to dissect his websites and some of the social media he was on”, Mr Israel said of the steps taken to look into Mr Cruz's background. He called some of the content “very disturbing”.

At around 4.15pm, police said the suspected shooter had been taken into custody after being tracked down without incident.

“It’s a horrific, horrific day. My triplets attended this school, and it’s horrible, just horrible,” Sheriff Israel said.

Jim Gard, a maths teacher at the school who said he taught Mr Cruz last year, told the Miami Herald that teachers had been warned not to let the former student on campus with a backpack.

“There were problems with him last year threatening students, and I guess he was asked to leave campus,” Mr Gard said.

Former classmates also has troubling memories of Mr Cruz. Jillian Davis, a recent graduate of the high school recalled his “strange talking, sometimes about knives and guns”.

Authorities confirmed that Mr Cruz was expelled from the school, but did not provide a reason why.

One student was texting with a CBS reporter from inside a closet in the school, and described a chaotic scene.

“All of a sudden there was a really loud noise... people are crying in the closet,” the student said.

Other parents said their children hid in classrooms until they were rescued by armed police in tactical gear.

“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 told the broadcaster. “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.”

Aerial footage from local news showed a number of people lying on the ground outside the school, and being treated for injuries. Meanwhile, dozens of emergency vehicles responded to the scene, including armed law enforcement.

US President Donald Trump paid tribute to the victims on Twitter.

Sending his “prayers and condolences to the families of the victims”, he later said he was ”working closely with law enforcement on the terrible Florida school shooting.”

Democratic Senator Chris Murphy, a prominent advocate for gun control, addressed the issue on the Senate floor that afternoon, urging his fellow legislators to take action. He had planned to discuss a separate issue, but spoke for several minutes on that day’s shooting.

“This happens nowhere else other than the United States of America – this epidemic of mass slaughter, this scourge of school shooting after school shooting,” said Mr Murphy, who represents the district where the Sandy Hook Elementary School shooting took place in 2012 where 26 people were killed.