by Audra D.S. Burch and Patricia Mazzei

PARKLAND, Florida — A heavily armed young man barged into his former high school about an hour northwest of Miami on Wednesday, opening fire on terrified students and teachers and leaving a death toll of 17 that could rise even higher, authorities said.

Students huddled in horror in their classrooms, with some of them training their cellphones on the carnage, capturing sprawled bodies, screams and gunfire that began with a few shots and then continued with more and more. The dead included students and adults, some of whom were shot outside the school and others inside the sprawling three-story building.

The gunman, armed with a semi-automatic AR-15 rifle, was identified as Nikolas Cruz, 19, who had been expelled from the school, authorities said. He began his shooting rampage outside Marjory Stoneman Douglas High School in this suburban neighbourhood shortly before dismissal time around 2:40 p.m. He then made his way inside and proceeded down hallways he knew well, firing at students and teachers who were scurrying for cover, the authorities said.

“Oh my God! Oh my God!” one student yelled over and over in one video circulating on social media, as more than 40 gunshots boomed in the background.

By the end of the rampage, Cruz had killed 12 people inside the school and three outside it, including someone standing on a street corner, Broward County Sheriff Scott Israel said. Two more victims died of their injuries in local hospitals. The aftermath at the school was an eerie shrine, with chairs upended, a computer screen shattered with bullet holes and floors stained with blood.

“This is catastrophic,” said Israel, who has three children who graduated from the high school. “There really are no words.”

Cruz was arrested in Coral Springs, a neighboring city a couple of miles from the school, about an hour after fleeing the scene, authorities said. He had slipped out of the building by mixing in with crowds of students. In addition to the rifle, Israel said Cruz had “countless magazines.”

The gunman had clearly prepared for the attack, Sen. Bill Nelson of Florida said in an interview after speaking to the FBI.

“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, citing details he learned from the FBI. Several students said they found it strange to hear the alarm, because they had already had a fire drill earlier in the day.

Israel said he did not know the gunman’s motive. He said a football coach was among the dead, and the son of a deputy sheriff among the injured. Twelve of the 17 dead had been identified by Wednesday night, he added, noting that not all of the students had backpacks or wallets on them.

Cruz was enrolled at another Broward County school, officials said. Israel said law enforcement officials had already discovered material on Cruz’s social media accounts that was “very, very disturbing.”

Jim Gard, a maths teacher at the school, said Cruz was in his class in 2016 and appeared to be a “quiet” student. But Gard also recalled that “there was concern” about his behavior on the part of the school administration, which emailed teachers relaying those fears.

Gard 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,” a point authorities did not raise in news briefings near the scene.

The massacre called to mind the country’s two mass shootings that have come to be known by the name of the schools: Columbine, the high school outside Denver where 12 students and a teacher were killed in 1999; and Sandy Hook, the elementary school in Newtown, Connecticut, where 20 students and six adults were shot dead in 2012.

More than 40 “active shooter” episodes in schools have been recorded in the United States since 2000, according to FBI and news reports. Two 15-year-old students were killed and 18 more people were injured last month in a school in rural Benton, Kentucky. The shootings have become common enough that many schools, including Stoneman Douglas High, run annual drills in which students practice huddling in classrooms behind locked doors.

With the Parkland shooting, three of the 10 deadliest mass shootings in modern US history have come in the last five months.

Nelson said the episode made him relive recent shootings that also shook the state. “Forty-nine slaughtered at the Pulse nightclub. Another handful slaughtered at the Fort Lauderdale airport, just a year ago, in the same county where this took place,” he said. “And that’s just Florida.”

After the gunfire had stopped Wednesday afternoon and Cruz had fled, students ran out of the school, some in single file with their hands on the shoulders of those in front of them and others in all-out sprints. As the students sought cover, law enforcement officers armed with military-grade weapons swarmed the building. Parents rushed to a local Marriott hotel to reunite with their children.

“I tried to stay calm. Students were running everywhere,” said Dianna Milleret, a 16-year-old sophomore who heard the gunshots.

Noelle Kaiser, 17, was in history class when a fire alarm went off. The class was gathered just outside the building when she heard three distinct gunshots.

“I am in shock,” she said softly after clutching her mother, Cheryl Kaiser, on the sidewalk outside the school.

Seventeen patients were treated in three area hospitals, including two who died, said Dr. Evan Boyar of the Broward Health System. All suffered gunshot wounds.

“Words cannot express the sorrow that we feel,” said Robert W. Runcie, the Broward schools superintendent. “No parent should ever have to send their kid to school and have them not return.”