The loaded .45 caliber weapon was found at the KIPP Dubois Collegiate Academy in the 5000 block of Parkside Avenue.
The student involved has only been identified as a 17-year-old male.
School officials say it began with an argument, and some students were sent to the principal's office.
That's when one student informed staff that another student had a gun.
"When the police ended up searching this young man's bag, they did find that he had a gun in his possession," said KIPP CEO Marc Mannella.
Officials say the student told police he carried the weapon for protection on his way to and from school. That student remained in police custody and will likely be expelled.
450 students attend the KIPP Dubois Collegiate Academy. It is a charter school run independently from the School District of Philadelphia, though it does get some district funds.
The school says it handles its own security. There are no security guards in the school and there are no metal detectors.
Instead, the school says it relies on what it calls a "Culture Team."
"We don't have dedicated security personnel, but there are three folks whose full-time job is school culture. It's the same function, but... it doesn't start with a suspicion of guilt, it starts with a suspicion of 'Let's build something,'" said Mannella.
Some worried parents came running to get take their children home.
"For us to get the phone call, for this to happen here? It's on the news all the time, you'll hear young men coming to school with guns and shooting up everybody. That's the first thing that came to mind, we had to get our kids," said Khadeja Barnes.
Officials say the system worked because they learned of the gun from another student and no one was hurt.