A fistfight between two gangs of girls that had been organized on Facebook erupted in gunfire last night outside a Southwest Philadelphia High School, leaving two young men and a 17-year-old girl wounded, police said.

The men, ages 19 and 22, were shot in the back and were reported in critical condition at the Hospital of the University of Pennsylvania this morning. The girl was treated at the hospital for a bullet wound to the buttock and released.

Lt. John Walker of Southwest Detectives said about 40 people, most of them teenage girls, had gathered outside Bartram High School at 66th and Elmwood for a fistfight about 11 p.m.

"It started with a dispute on Facebook," said Walker.

He said the conflict pitted a group of girls from Southwest Philadelphia with a rival group from West Philadelphia and had been triggered by "inappropriate comments" posted on the social networking Web site.

"One of the girls said, 'enough is enough,'" said Walker, and both sides agreed to a rumble through Facebook exchanges.

Each side came with some males in their company, he said.

Walker said the girls had started brawling when at least 15 shots were fired from at least two handguns - a 9mm and a .40-caliber - hitting the three victims.

The relationship of the victims to one another is not yet clear. School District officials said none of the three had a connection to Bartram.

Most of the girls had fled by the police arrived and Walker said investigators hoped more witnesses would step forward.

Anyone with information was asked to call Southwest Detectives at 215-686-3183 or 3184.