At least four students were critically injured in the shocking assault at Franklin Regional High School, said Thomas Seefeld, chief of police in Murrysville, an outer suburb of Pittsburgh.
The 16-year-old boy walked down a hallway flashing two knives, stabbing fellow pupils and the guard as they began arriving for what should have been a routine school day, Seefeld said.
Nineteen students and one male security guard were injured, mostly in the chest and stomach, officials confirmed.
The school principal and another member of staff tried to overpower the suspect who was then arrested, Seefeld said.
Officials said the assault began at 7:13 am (1213 GMT) was over by 7:45 am.
It was not immediately clear what prompted the assailant, who is himself being treated for a hand injury, to attack.
Doctor Mark Rubino at Forbes Regional Hospital, which is treating eight of the victims, said he expected everyone to survive despite what he called "deep penetrating" stab wounds.
The knife wounds, most of them to the lower abdomen, caused significant injuries to internal organs, Rubino said.
Three of the victims were still in surgery and the other five were still being evaluated, he told reporters.
"Three of the patients had severe injuries and are still in the operating room right now. And two of them are in critical condition, but they have stabilized," Rubino said.
The other five that we had are still being evaluated, of whom one or two may require further surgery, he added.
Dan Stevens, a spokesman for Westmoreland County emergency management, told AFP that the teenage victims are aged 14 to 17.
They were attacked in "numerous classrooms and hallways" of the school, Stevens added.
Police said the victims were found in multiple locations because they were following the correct drill to run as far away as possible in the event of an emergency.
Wednesday's attack comes after a long and frequent line of US school shootings that have inflamed a nationwide debate over gun control in the United States.
But even the December 2012 massacre at Sandy Hook Elementary in Newtown, Connecticut, where 20 young children and six adults were shot dead, ultimately failed to tighten gun ownership rules.
Seefeld praised school staff, who worked in close coordination with police and who were well versed in emergency procedure.
"It is my opinion that today as unfortunate as it is... I think that it could have been a lot worse if there was not immediate interaction that occurred," he told reporters.
The school has since been evacuated.
A statement on the website of the Franklin Regional School District said a "critical incident" had occurred.
"All elementary schools are cancelled, the middle school and high school students are secure," the statement said.