A police stands by caution tape at the Delaware Valley charter school on Friday Photograph: Matt Rourke/AP

A boy who was hanging out in a high school gym with fellow students on Friday afternoon shot and wounded two of them before fleeing and being captured near his home, police said. The shooting happened at the Delaware Valley Charter High School in north Philadelphia around 3 pm, authorities said.

Surveillance video shows a group of about seven students hanging around when the shooting happened, police commissioner Charles Ramsey said. It was unclear if the shooting was accidental or intentional but it "doesn't look like an active shooter type of situation", he said.

A male student and a female student were shot, each in an arm, but it was unclear whether one or two shots were fired, Ramsey said.

The wounded students, believed to be 15 years old, were taken to a hospital near the school, where they were listed in stable condition, police said. The shooter lives miles away from the school in south Philadelphia and may have driven or taken a bus home after the shooting, Ramsey said. No gun was recovered, he said.

Ramsey didn't know what staffing or security procedures were in place at the school but said "there was a breakdown in security of some kind" because the gun had got into the building.

The school was placed on lockdown and secured by SWAT officers checking each room. Students were searched and released one by one.

A spokesman for the school district didn't immediately respond to a call seeking comment. The president of the charter school's board of trustees said he didn't have any additional information about the shooting, the second US school shooting this week.