A gunman opened fire at a South Florida high school on Valentine's Day, killing at least 17 people in the deadliest school shooting since Sandy Hook in 2012.

The shooter, identified as Nikolas Cruz, 19, had been expelled from the school for “disciplinary reasons," Broward County Sheriff Scott Israel said.

Gunfire erupted near the end of the school day Wednesday afternoon at Marjory Stoneman Douglas High School in Parkland.

Cruz was taken into custody off campus, then put into an ambulance and taken to a hospital. Israel said Cruz was taken into custody without incident, Israel said.

The sheriff said at a 6:30 p.m. news conference that 17 people were confirmed dead.

At a Wednesday night briefing, the sheriff said 12 of the 17 people have been identified, some of them being children. A football coach was also killed, and the son of a deputy is reportedly recovering from being shot in the arm.

The Broward County School District says the school will be closed Thursday and Friday. All activities will be canceled. 

Cruz, who officials say 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.

Israel said the shooter was both inside and outside the school during the incident. He earlier added that efforts were being made to reunite parents with their students.

"It's catastrophic. There really are no words," Israel said.

Surgeons who aided in treating victims of the shooting at two Broward Health System hospitals told reporters that two victims died at those locations, while two others were listed in 'critical' condition and three more were listed in 'stable' condition.

At 4:11 p.m., the Broward County Sheriff's Office posted on Twitter that the shooter was in custody. Its first tweet about the shooting was at 2:53 p.m.

A law enforcement official says Cruz allegedly posted highly disturbing material on social media before the shooting rampage.

Israel says investigators are dissecting the suspect’s social media posts and found material that is “very, very disturbing.” He didn’t elaborate.

An ex-schoolmate recalled Cruz posting on Instagram about killing animals and said he talked of doing target practice in his backyard with a pellet gun.

A school superintendent, Robert Runcie, told reporters he didn’t know of any concerns raised about Cruz.

Gov. Rick Scott ordered flags to fly at half-staff until Monday, Feb. 19 to honor the victims of the shooting.

Television video showed students running from campus with their hands behind their heads. A police officer waved the students on, urging them to quickly evacuate. The students made their way out past helmeted police in camouflage with weapons drawn.

Ambulances converged on the scene as emergency workers appeared to be treating wounded people on the sidewalks.

A student who escaped the deadly shooting at the high school says he knew the suspect when he attended the school, describing him as a “weird kid” and something of a “loner.”

Len Murray's 17-year-old son, a junior at the school, sent his parents a chilling text around 2:30 p.m.: "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."

The school is on Pine Island Road. Authorities are telling residents there to avoid the area of Marjory Stoneman Douglas High School.

Gov. Scott was briefed on the shooting and was at a presser at the high school Wednesday night. The Federal Bureau of Investigation has responded as well, who established a tipline about the shooting. Anyone with information is asked to call 1-800-CALL-FBI.

Broward County Schools Superintendent Robert Runcie called what happened a horrific siutation.

"It is a horrible day for us," Runcie said.

The high school is a sprawling complex set on a tract in the South Florida community of Parkland, about 45 miles north of downtown Miami. It canceled after-school activities Wednesday night.

Caesar Figueroa said when he got to the school to check on his 16-year-old daughter, he saw police officers drawing machine 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.

At the Wednesday night presser, Sheriff Israel said that he thinks more mental health funding is needed, though someone with a mental health issue should not be able to get their hands on a gun. 

It's only February, and there have already been at least four shootings at middle and high schools in the United States so far this year. That's according to CNN.

Parkland was actually voted Florida's safest city last year, according to an analysis by the Washington-based National Council for Home Safety and Security. The group said the south Florida city, with a population of 31,507, had only seven reported violent crimes and 186 property crimes the previous year.

Broward County Public Schools will provide grief counseling on Feb. 15 starting at 8 a.m. for students, families, and Marjory Stoneman Douglas High School staff members at five locations. Click HERE for location information.

Stay with Spectrum Bay News 9 and Spectrum News 13 for updates.

The Associated Press contributed to this story.

Interactive timeline: Parkland shooting

Twitter Moment