Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A student flashing two knives went on a stabbing rampage through the classrooms and halls of a high school outside Pittsburgh on Wednesday morning, authorities said. At least 19 students and a security guard were hurt, some with life-threatening injuries.

The suspect, a 16-year-old sophomore, was in custody and being questioned by police, authorities said. His motive was unclear, said Dan Stevens, a Westmoreland County emergency management spokesman.

The first photo of the suspect emerged several hours after the mayhem. NBC News is blurring the face of the teen in the photo, from the Pittsburgh Tribune-Review, because of his age. He had not been charged or identified.

A suspect in the Franklin Regional High School stabbings leaves the Murrysville Police Station on Wednesday. Image blurred to protect identity. Guy Wathen / Tribune-Review

The student was “flashing two knives around” as he moved through the classrooms and a first-floor hallway, said Thomas Seefeld, the Murrysville police chief. A principal tackled the stabber, he said. The security guard suffered a stomach wound.

The attack happened at Franklin Regional High School, in the suburb of Murrysville, just after doors opened for the day. A student described panic in the halls.

“I was walking into the school and a stampede of people were running after me,” said the student, Kari Lee, who said several of her friends had been knifed. “They were screaming, ‘Go to your cars! Go to your cars! Someone is stabbing people!’”

A doctor at one hospital, UPMC Presbyterian, said the attack appeared to have been carried out with a long knife.

A 17-year-old boy was on life support at that hospital after the knife pierced his liver, his diaphragm and several major blood vessels. It missed his heart by millimeters, a doctor told reporters.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The boy was on life support Wednesday afternoon and will need blood transfusions and additional surgery, but doctors said they were optimistic that he would survive.

In all, 21 people were taken to the hospital, at least four critically. The 21 injured included the 19 students, the security guard and a second adult who had what hospital officials described as a “medical condition” during the attack.

Seven teenagers and an adult were taken to Forbes Regional Hospital, Dr. Chris Kauffman, the trauma director there, told NBC News. The seven were stabbed in the chest, back and abdomen, he said. He characterized some of the injuries as life-threatening but said everyone was expected to live.

At least three students were in surgery. Others were undergoing CT scans and X-rays and could require surgery later, Kauffman said.

He described the knife wounds he saw as several inches deep and “impressively large holes in each of the patients that I saw. More than an inch.”

Asked how close a call it was for the victims, he said: “Very close. Minutes.”

One girl may have saved the life of one of the stabbed by applying pressure to his wounds, hospital officials said. The girl was not hurt.

“She displayed an amazing amount of composure to help that friend, who was having significant bleeding,” said Dr. Mark Rubino, a surgeon at Forbes hospital.

Stevens told WPXI, the NBC affiliate in Pittsburgh, that the first call for help from the school came at 7:13 a.m. The situation was under control by 7:30 to 7:40, he said.

Someone pulled a fire alarm in the chaos. A school principal was “the lead” to taking the suspect into custody, the police chief said, before the security guard applied handcuffs.

Ambulances swarmed the parking lot of the high school, and nearby streets were sealed off.

The school district said that high school students and middle school students nearby were “secure,” and that elementary school had been canceled for the day. Parents were asked to report to an elementary school to pick up their children.

Students who drove to school were not allowed to drive home without a parent, according to the district.

The high school has about 1,200 students. Murrysville, about 20 miles east of Pittsburgh, is a city of 21,000. Renatta Signorini, a reporter for the Tribune-Review, told MSNBC that it is a city with low crime.

She said that the schools there do not have metal detectors but have been updating their security procedures. The police chief declined to comment on the school security measures.

The attack came exactly one year after a college student in Texas brandishing a utility knife ran through two floors of a campus building, injuring 14 people.

Pennsylvania Gov. Tom Corbett said that he was shocked and saddened. He said he had directed the state police to help and would make other state resources available.

Tracy Connor and Erik Ortiz of NBC News contributed to this report.