Authorities said the suspect, identified as 19-year-old Nikolas Cruz, concealed himself in the crowd fleeing Marjory Stoneman Douglas High School. He was arrested in nearby Coral Springs and later charged with 17 counts of premeditated murder.

Cruz had recently been expelled from Douglas for disciplinary reasons and was enrolled elsewhere in the district, Broward County schools Superintendent Robert Runcie said.

The gunman was believed to have been armed with a AR-15-style semiautomatic rifle and multiple magazines, Broward County Sheriff Scott Israel. It was unclear whether he had any other weapons, Israel said.

Cruz was taken into custody off campus about an hour after he "committed this horrific, detestable act," said Israel, who added investigators were reviewing social media postings that he described as "very disturbing." The suspect was treated for "labored breathing" as a precaution but was later released from the hospital, according to officials.

"You come to the conclusion this is just absolutely pure evil," said Florida Gov. Rick Scott, his hands clutched over his chest.

Scott, a Republican whom the National Rifle Association's Political Victory Fund gave an "A+" rating, didn't address reporters' questions about how the gunman was able to obtain a semiautomatic rifle.

What we know so far:

17 people were killed, according to officials, both inside and outside Marjory Stoneman Douglas High School in Parkland, Florida

The shooting started around 2:30 p.m. ET on Wednesday as the fire alarm sounded

A suspect, Nikolas Cruz, 19, a former Douglas High student believed to have been armed with a semiautomatic rifle and multiple magazines, is in custody

The FBI was alerted six months ago after a YouTube user named "Nikolas Cruz" posted a comment stating "I'm going to be a professional school shooter" on the video site, BuzzFeed reported early Thursday.

Cruz's mother died in early November and he had been staying with a local family — whose son is a junior at Douglas, the family's attorney told NBC Miami.

"He lived here without any concerns or issues for almost three months and they are shocked and horrified by the allegations being made," lawyer Jim Lewis said, adding that his clients are fully cooperating with investigators.

The general store chain Dollar Tree confirmed that Cruz worked at its Parkland branch and said it was fully cooperating with investigators.

The gunfire began outside the school and continued inside, where 12 of the victims were killed, Israel said.

All of those victims have been identified, he said, but no identities will be made public until the families of all of those affected have been notified.

Sebastian Toala, another senior, told NBC Miami: "I never really got close to him, because I always had a feeling there was something wrong."

Parkland, in north Broward County, is about 30 miles northwest of Fort Lauderdale. The shooting on the sprawling campus happened despite the presence of police officers at the school.

Runcie, the school superintendent, said at last two police cars were typically on campus "on a daily basis."

While students filed out of the school with their hands up, heavily armed SWAT team members conducted a class-by-class search to make sure there were "no other shooters" — and to retrieve any bodies, he said.

"This is a terrible day for Broward County, the state of Florida, the United States," he said. "There really are no words."

The first sign that something awful was happening came around 2:30 p.m., not long before classes were supposed to have been dismissed, when authorities were called to respond to an active shooter.

Not long after, stunned survivors began sharing their accounts of what happened.

"I was on the first floor of the building where the shots happened first," freshman Jason Snytte told NBC News. "I was in the classroom right next to the outside, the closest classroom to it. It started there. I heard six or seven shots. Our door was open. I ran and closed it, and everybody ran into a corner."

Jason, who said the shots were deafening, said they listened to their teacher and stayed put until police arrived and told them to evacuate.

"We were all freaking out. Our hearts were racing," he said. "We didn't know what was happening."

Several students told NBC News that the school had gone through a fire drill earlier in the day. They said the fire alarm sounded again just before the shots were heard.

Relieved parents like Lisette Rozenblet, whose daughter attends the school, also said she was told that a fire alarm was pulled about the time the shots began. But her daughter's teacher, sensing that it might be a trap, told the students to stay in the classroom, she said.

"Her biggest fear is a school shooting," Rozenblet said of her daughter. "She is always begging me to be home-schooled because she was scared of this."

Joel Leffler, whose son and daughter attend the school, said both of his kids were safe — but in shock.

"My son called me as it was unfolding, running. He had to jump a fence," Leffler said. "My son heard around eight gun shots as he was running out."

When he reached his daughter by phone, she was whispering, he said.

"My daughter, who was there in the freshman hall where the shooting took place — she's in shock right now, and she's being taken out by SWAT," Leffler said. "She saw multiple dead bodies."

Scott traveled to Broward County to be briefed by emergency management officials and law enforcement. The governor said he had been in touch with Trump and the Department of Homeland Security.

Scott didn't address reporter's questions Wednesday night about whether the gunman should have been able to obtain a semiautomatic rifle.

The governor, a Republican who has an "A+" rating from the National Rifle Association's Political Victory Fund, said: "There is a time to continue to have these conversations about how, through law enforcement, how through mental illness funding, to keep people safe, and we'll continue to do that."