Police said a former student opened fire at a Florida high school on Wednesday, killing at least 17 people and sending scores of students fleeing into the streets in the nation's deadliest school shooting since a gunman attacked an elementary school in Newtown, Conn.

The shooter, who was equipped with a gas mask and smoke grenades, set off a fire alarm to draw students out of their classrooms shortly before the school day ended, officials said.

Students wait to be picked up near the school, which had some 3,100 students in 2016-17. (Wilfredo Lee/Associated Press)

Authorities offered no immediate details on the 19-year-old suspect or any possible motive, except to say that he had been kicked out of Marjory Stoneman Douglas High School, which has about 3,000 students.

Students who knew the shooter, identified as Nikolas Cruz, described a volatile teenager whose strange behaviour had caused others to end friendships with him, particularly after the fight that led to his expulsion.

'A horrific situation'

Frantic parents rushed to the school to find SWAT team members and ambulances surrounding the campus as classes prepared to dismiss for the day. Live footage showed emergency workers who appeared to be treating the wounded on sidewalks.

"It is a horrific situation," said Robert Runcie, superintendent of the school district in Parkland, Fla. "It is a horrible day for us."

Today we experiencing the worst of humanity as an unspeakable tragedy has hit our <a href="https://twitter.com/browardschools?ref_src=twsrc%5Etfw">@browardschools</a> family at Marjory Stoneman Douglas HS. There has been a shooting on campus with injuries and fatalities. We are working with law enforcement as we pray for our babies and families. —@RobertwRuncie

The suspect was taken into custody without a fight about an hour after he left the scene, authorities said.

"It's catastrophic. There really are no words," Broward County Sheriff Scott Israel told reporters.

Used fire alarm as lure

The attacker used the fire alarm "so the kids would come pouring out of the classrooms into the hall," Sen. Bill Nelson said in an interview on CNN.

"And there the carnage began," said Nelson, who said he was briefed by the FBI.

A law enforcement officer directs traffic outside the school. (John McCall/South Florida Sun-Sentinel via AP)

The Florida Democrat said he did not know if the assailant used the smoke grenades, but he assumed that's why he had a gas mask on.

Most of the fatalities were inside the building, though some victims were found fatally shot outside, the sheriff said.

Abusive to girlfriend

Victoria Olvera, a junior at the school, said Cruz was expelled last school year because he got into a fight with his ex-girlfriend's new boyfriend. Olvera said he had been abusive to his girlfriend.

"I think everyone had in their minds if anybody was going to do it, it was going to be him," she said.

Students held onto other students as they made their way out past helmeted police in camouflage with weapons drawn. (Joe Raedle/Getty Images)

Dakota Mentcher, another junior, said he used to be friends with Cruz. But he cut off the friendship as Cruz's behaviour "started progressively getting a little more weird." Cruz posted on Instagram about killing animals and threatened one of Mentcher's friends, he said.

He remembered that Cruz had a pellet gun and did target practice in his backyard.

'That weird kid'

Student Daniel Huerfano said he recognized Cruz from an Instagram photo in which Cruz had posed with a gun in front of his face.

Cruz "was that weird kid that you see … like a loner," he said.

Sarah Crescitelli leans on her mother, Stacy Crescitelli, left, after she escaped the shooting. (Joe Raedle/Getty Images)

Freshman Max Charles was in class when he heard five gunshots.

"We were in the corner, away from the windows," he said. "The teacher locked the door and turned off the light. I thought maybe I could die or something."

Suspect released to police

As he was leaving the building, he saw four dead students and one dead teacher. He said he was relieved when he finally found his mother.

"I was happy that I was alive," Charles said. "She was crying when she saw me."

Just spoke with <a href="https://twitter.com/POTUS?ref_src=twsrc%5Etfw">@POTUS</a> about shooting at Marjory Stoneman Douglas High School. My thoughts and prayers are with the students, their families and the entire community. We will continue to receive briefings from law enforcement and issue updates. —@FLGovScott

Dr. Evan Boyar at Broward Health North told reporters Wednesday that eight victims and the suspect had been brought to his hospital. Boyar said two victims died, three were in critical condition and three were in stable condition. He said three patients were still in the operating room Wednesday evening. The suspect was treated and released to police.

Boyar said all the victims were shot but he declined to comment on their ages or the extent of their wounds.

He said eight other victims were taken to other hospitals, but he did not have information on their conditions.

'Get on the ground!'

The high school is a sprawling complex set on a tract in the South Florida community of Parkland, about 70 kilometres north of downtown Miami.

The school had just over 3,100 students in the 2016-17 academic year, according to the National Centre for Education Statistics. Major streets run along two sides and an expressway passes nearby on the other not far from a residential neighborhood of single family homes.

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. —@realDonaldTrump

In a cul-de-sac near the school, Michael Nembhard was sitting in his garage when he saw a young man in a burgundy shirt walking down the street. In an instant, a police cruiser pulled up and officers jumped out with guns drawn.

"All I heard was 'Get on the ground! Get on the ground!'" Nembhard said. He said he could not see the young man's face, but that he got on the ground without incident.

'Mom, I'm so scared'

The day started normally at the school, which had a morning fire drill, and students were in class around 2:30 p.m. ET when another alarm sounded.

Noah Parness, 17, said he and the other students calmly went outside to their fire-drill areas when he suddenly heard popping sounds.

"We saw a bunch of teachers running down the stairway, and then everybody shifted and broke into a sprint," Parness said. "I hopped a fence."

Beth Feingold said her daughter, Brittani, sent a text at 2:32 p.m. that said, "We're on code red. I'm fine," but sent another text shortly afterward saying, "Mom, I'm so scared."

Brittani later was able to escape the school, which is one of the largest in the state.

'I'm scared for the other parents here'

Inside the school, students heard loud bangs as the shooter fired. Many of them hid under desks or in closets and barricaded doors.

Television footage showed those students who fled leaving in a single-file line with their hands over their heads as officers urged them to leave the area quickly. Parents hurried to the scene.

Caesar Figueroa said when he got to the school to check on his 16-year-old daughter, he saw police officers drawing guns as they approached the campus.

"My wife called me that there was an active shooter, and the school was on lockdown. I got on the road and saw helicopters… It was crazy and my daughter wasn't answering her phone." She finally texted him that she was inside a closet with friends.

Len Murray's 17-year-old son, a student at the school, sent his parents a chilling text: "Mom and Dad, there have been shots fired on campus at school. There are police sirens outside. I'm in the auditorium and the doors are locked."

A few minutes later, he texted again: "I'm fine."

Murray said he raced to the school only to be stopped by authorities under a highway overpass within view of the school buildings. He said he told his son to save his battery and stop texting. The boy's mother told him to turn off his ringer.

Authorities told parents to gather at a nearby hotel to get information.