It happened when administration and security were alerted to a student who seemed to be under the influence.
Authorities say it was a teacher who first noticed the student acting strangely.
"An alert teacher noticed that a student was not acting normal, was impaired," said Superintendent of Upper Darby Police Tim Bernhardt.
The student was taken out of class and down to an administrator's office. Investigators say while searching that student, school administrators found the student to be in possession of a loaded handgun.
Officials said the student also had marijuana.
That's when school leaders immediately called the police.
"Our officers responded to the school. They took the student and the handgun out of the school," said Bernhardt. "It was terrifying for everyone."
The student is now set to face charges, according to police.
School leaders said all safety procedures were followed and no injuries were reported.
"Today, our staff and students did an outstanding job implementing our emergency response procedures," Superintendent Daniel McGarry said in a statement. "I understand how alarming this communication is for all involved, but I am grateful that our safety procedures were followed and that no one was injured."
McGarry went on to say the school will have pupil service professionals available for students who need to speak with someone.
Action News spoke with people in the area, who said they were shocked by this incident.
"These young kids have no respect for anybody," said Mark Fields from West Philadelphia.
"They feel like they can just do anything and get away with it now," added Mitchell Parker from Wilkes-Barre.
The 6abc Data Journalism team found during the 2021-2022 school year, nearly 5,000 public school students in the U.S. brought a gun to school, including 40 students in Pennsylvania.
While that was the second-highest number on record for the state, Pennsylvania's rate was actually the fourth lowest in the country.
Bernhardt says police met with school district officials on Tuesday to discuss issues like this incident. He says this situation can be a teaching moment for parents and guardians.
"This is a perfect opportunity to remind students, kids, to not play with guns and that there is no business with anyone having a gun on them on any school property," Bernhardt said.
Authorities say they are now investigating where the student got the handgun. Depending on that answer, more charges could be filed.