At least 17 students and teachers were killed as a heavily-armed 19-year-old went on a shooting spree outside and inside his former high school in Florida state in the US, authorities said. The shooter was arrested an hour later.

The horrific violence unfolded on Wednesday at Marjory Stoneman Douglas High in Parkland, which ironically was voted Florida's safest city last year.

The gunman, armed with a semi-automatic AR-15 rifle, was identified as Nikolas Cruz, who had been expelled from the school for "disciplinary reasons", the New York Times reported.

He began his rampage outside the school shortly before dismissal time around 2.40 p.m. He then made his way inside and proceeded down hallways, firing at frightened students and teachers who were scurrying for cover.

Students huddled in horror in their classrooms, with some using their phones to share the massacre on social media. Footage showed sprawled bodies, screams and gunfire that began with a few shots and then seemed to go on and on.

Cruz killed 12 people inside the school and three outside, Broward County Sheriff Scott Israel said. Two more victims succumbed in hospitals.

The mass murderer was arrested at Coral Springs, a neighbouring city, about an hour after fleeing the scene, the authorities said. He had slipped out of the building by mixing in with crowds of panicky students.

In addition to the rifle, Sheriff Israel said Cruz had "countless magazines".

Students recalled terror and confusion in the aftermath of the shooting. An English class was going on when the shooting began.

"We had a fire drill early in the day, so we really didn't know what was going on," said Ryan Kadel, a 17-year-old student. "We went outside and we saw a security guard on a golf cart driving really fast and yelling at us to run."

The gunman had clearly prepared for the attack, Senator Bill Nelson of Florida said after speaking to the FBI, the Times said.

"The shooter wore a gas mask, had smoke grenades and he set off the fire alarm so the kids would come out of the classrooms," said Nelson.

Sheriff Israel said he did not know the gunman's motive. He said a football coach was among the dead. Twelve of the 17 dead had been identified by Wednesday night.

Cruz was enrolled at another Broward County school. Sheriff Israel said law enforcement officials had discovered "very, very disturbing" material on Cruz's social media accounts.

His Instagram account showed several photos of guns. One appeared to show a gun's holographic laser sight pointed at a neighbourhood street. Another showed six rifles and handguns laid out on a bed. The most disturbing appeared to show a bloodied dead frog.

Jim Gard, who was Cruz's maths teacher at the school in 2016, said the student appeared to be a "quiet" one. He said that after the shooting, he learned from several students that Cruz was obsessed with a girl at the school to the point of stalking her, the Washington Post reported.

The shooting, among the 10 deadliest mass shootings in modern US history, revived debate over gun control while American politicians offered their condolences.

"My prayers and condolences to the families of the victims of the terrible Florida shooting. No child, teacher or anyone else should ever feel unsafe in an American school," US President Donald Trump said.

( IANS)

Police escort a suspect into the Broward Jail after checking him at the hospital following a shooting
Police escort a suspect into the Broward Jail after checking him at the hospital following a shooting. Reuters
Police escort Nikolas Cruz into Broward County Jail following a shooting incident
Police escort Nikolas Cruz into Broward County Jail following a shooting incident at Marjory Stoneman Douglas High School, in Fort Lauderdale, Florida, U.S. February 15, 2018 in a still image from video. Reuters
Nikolas Cruz appears in a police booking photo after being charged with 17 counts
Nikolas Cruz appears in a police booking photo after being charged with 17 counts of premeditated murder following a Parkland school shooting, at Broward County Jail in Fort Lauderdale, Florida, U.S. February 15, 2018. Reuters
A man is approached by police officers, following a shooting incident in Parkland, Florida
A man is approached by police officers, following a shooting incident in Parkland, Florida, U.S. February 14, 2018 in this still image obtained from the social media video. Picture taken February 14, 2018. Reuters
Rescue workers deal with a victim near Marjory Stoneman Douglas High School during a shooting incident in Parkland, Florida
Rescue workers deal with a victim near Marjory Stoneman Douglas High School during a shooting incident in Parkland, Florida, February 14, 2018 in a still image from video. WSVN.com via REUTERS Reuters
Students are evacuated from Marjory Stoneman Douglas High School during a shooting incident in Parkland, Florida
PARKLAND, UNITED STATESStudents are evacuated from Marjory Stoneman Douglas High School during a shooting incident in Parkland, Florida, February 14, 2018 in a still image from video. WSVN.com via REUTERS Reuters
a shooting incident in Parkland, Florida
A man placed in handcuffs is led by police near Marjory Stoneman Douglas High School following a shooting incident in Parkland, Florida, February 14, 2018 in a still image from video. WSVN.com via REUTERS Reuters
 shooting incident at Marjory Stoneman Douglas High School in Parkland, Florida
A man who was placed in handcuffs by police is loaded into a paramedic vehicle after a shooting incident at Marjory Stoneman Douglas High School in Parkland, Florida, February 14, 2018 in a still image from video. WSVN.com via REUTERS Reuters
Police cars are seen in Coral Springs after a shooting at the Marjory Stoneman Douglas High School in Parkland, Florida
Police cars are seen in Coral Springs after a shooting at the Marjory Stoneman Douglas High School in Parkland, Florida, February 14, 2018 in this image obtained from social media. TWITTER / @GRUMPYHAUS via REUTERS Reuters
Rescue workers prepare to transport a victim on a stretcher near Marjory Stoneman Douglas High School
Rescue workers prepare to transport a victim on a stretcher near Marjory Stoneman Douglas High School. Reuters
A man placed in handcuffs by police is wheeled on a stretcher into a hospital near Marjory Stoneman Douglas
A man placed in handcuffs by police is wheeled on a stretcher into a hospital near Marjory Stoneman Douglas. Reuters