A fight among students from rival schools exploded Wednesday afternoon as someone fired gunshots into a crowded subway car on the Broad Street Line in North Philadelphia, police said, injuring two teenagers and causing panic among passengers.

A 17-year-old who was hit in an arm and a 14-year-old who was shot in a leg were taken to Temple University Hospital, where they were in stable condition within hours of the shooting, police said. It was unclear whether they were the intended targets, police said.

At least one teenager was taken into custody, but police said they were still searching for the gunman Wednesday night. Investigators were reviewing surveillance footage and talking with witnesses.

A police source said the fight was among students from Simon Gratz High School, Samuel Fels High School, and John F. Hartranft, a kindergarten-through-eighth-grade school.

Courtney Collins-Shapiro, an executive with Mastery Charter Schools, said she could not confirm reports that one of the students involved attended Gratz, a Mastery school. She said school officials were talking to police and trying to get more information.

Collins-Shapiro said officials had been keeping a close eye on safety at Gratz recently.

"There have been a lot of rumors and tension in the neighborhood for the last week, and we've been on high alert at the school," Collins-Shapiro said. She said Gratz administrators had implemented a "Safe Corridors" program, escorting students to buses and subways.

SEPTA Transit Police Chief Thomas Nestel said authorities believed the shooter was a high school student.

"It's certainly the assumption we're making, that this is high school kids, but we don't know," he said.

The Broad Street Line has a daily average ridership of a little more than 130,000 people, said SEPTA spokesman Andrew Busch. Trains were diverted for more than an hour, but all Broad Street Line service was restored around 3:30 p.m.

The after-school commuter rush was in full swing when mayhem began shortly before 2 p.m. near Broad and Dauphin Streets. Students crowded onto the southbound subway cars, jostling and arguing. When the train pulled into the Susquehanna-Dauphin station in North Philadelphia, a male fired a gun from the platform into the car, which was packed, mostly with teenage students.

Passengers began screaming and running for safety, police said. Officers tracked one of the teenagers running from the scene to nearby Carlisle Street and took him into custody for questioning, Nestel said.

While police were investigating underground, juveniles in gray high school uniforms were led out of the subway and into SEPTA Transit Police cars. It was unclear whether the youths were witnesses.

"This is an issue of the kids choosing to act like young adults," Nestel said. "They're not, and until they do, the School District and the police will be giving them lots of added attention."

Terry Starks of Philadelphia CeaseFire, a violence-reduction program, said he would be visiting one victim at the hospital.

"I'm the first person he is going to see when he wakes up," Starks said.