Two people were killed and one wounded Thursday night when a pair of would-be armed robbers pulled a gun on a man walking in West Philadelphia - and the man, in turn, pulled his own gun and fired.

Police said the man, 27, and his friend, 25, had just gotten off a trolley and were walking along the 5400 block of Media Street when they passed two other men, who announced a robbery. The man and his friend turned around to see one of the alleged assailants holding a gun.

The 27-year-old pulled a semiautomatic handgun that he was legally permitted to carry and fired at the other men, emptying his gun, a law enforcement source said.

One of the alleged assailants, shot in the chest and groin, tried to run but fell to the ground. He was pronounced dead at Penn Presbyterian Medical Center.

The other man, hit in the spine, made it over a fence and into a nearby backyard, where he, too, collapsed, police said. He was subsequently found by police and taken to Penn Presbyterian, where he was listed in critical condition.

The 25-year-old also was shot and killed. Police had not yet determined who fired the shot that killed him.

Two guns were recovered at the scene.

The identities of the victims and the alleged assailants had not been released by Friday night.

awhelan@philly.com

215-854-2961

@aubreyjwhelan