The shootings happened about 15 minutes before classes were to start at Red Lion Area Junior High School.
"Everyone ran out of the cafeteria yelling, 'He has a gun!"' eighth-grader Danny Dulin said.
Principal Eugene Segro, 51, who was shot once in the chest, was pronounced dead at a hospital. James Sheets, 14, died at the scene of a shot to the head, Coroner Barry Bloss said.
Sheets brought three loaded handguns to school in his backpack and used at least two of them in the shootings, police said. The principal was killed with a .44-caliber weapon, while the student was believed to have been killed with a .22-caliber weapon.
Officials did not know of any school or legal problems the boy was facing, and said his parents had no reason to expect anything was wrong.
"We don't know why, period," Red Lion Borough Police Chief Walt Hughes said. "I think it's safe to say that something was building inside of him that he couldn't control."
The guns belonged to his stepfather, Arthur Baker, police said. Sheets had used a key to remove them from a safe at his house, apparently on Thursday morning, police said.
Sheets was not known for being a disciplinary problem, and police and Red Lion Area Superintendent Larry Macaluso did not know him to have any specific disputes with Segro.
Police later searched the Red Lion home of his mother and stepfather, removing a computer and many bags and boxes, officials said.
No charges were expected to be filed against the parents, Hughes said. A message left at the home Thursday was not immediately returned.
Sheets was an athletic boy who played on the school football team and could often be found skateboarding or shooting hoops in his rural subdivision, neighbors and fellow students said. Police believe he acted alone.
Segro had been at the school more than a decade, a school official said.
"He tried to find the most lenient way to punish the kids. It wasn't just a job for him. He truly loved the kids," said Nicole Wisor, 16, a 10th-grader who had attended the school.
Autopsies were being conducted on both victims Thursday. Bloss said a third shot was fired, but apparently hit the floor.
The room fell silent after the shootings, then students began running outside or toward their homerooms, said Angel Williams, 14, a seventh-grader.
Officials dismissed the school's nearly 900 students for the day, and also sent home students from the high school and elementary school. Students who witnessed the shooting met with counselors, police said.
The junior high was to remain closed Friday.
The school does not have metal detectors but does have security cameras, according to Terry Robinson, the school district's business manager.
The same school district was the site of a machete attack on a kindergarten class that injured a principal, two teachers and 11 of the 23 pupils in 2001. A man angry about his divorce and allegations he had molested his stepdaughters was sentenced to 132 to 264 years in prison.