It happened at around 10:30 Sunday night at the Wingstop in the 2100 block Cottman Avenue.
Police said the suspect, a 53-year-old man, came in wearing a mask and gloves.
"(He) walked in, went behind the counter, announced a robbery and asked for all the money," said Philadelphia Police Department Chief Inspector Scott Small.
Before the three employees who were inside could comply with his demands, a customer walked in talking on his cell phone.
"That's when the robber pointed a gun at that customer and demanded his cell phone," said Small, who added that the 27-year-old customer quickly decided to fight back.
"(He) pulled his gun (and) fired one shot at the perpetrator, striking him in the neck," Small said.
The customer, who does have a valid permit to carry a weapon, stayed on the scene and cooperated with police.
"We do have his weapon. We know that's just one shot was fired from that customer because we found one spent shell casing on the floor on the customer side of the counter," said Small.
News of the incident garnered a strong reaction from residents in the area.
"The guy that was robbing the place deserved what he got, in my opinion," said Marius Maiellano of Olney. "Pull a gun on somebody, expect to get shot."
Police found the suspect lying on the floor behind the counter, bleeding. He was pronounced dead at the scene. Police say the suspect had prior run-ins with the law.
The customer and the employees talked with homicide detectives who will look to surveillance cameras inside the restaurant, to make sure that the entire story checks out.
At this point, police said it does not look like the customer who fired the fatal shot will face any charges.