It happened around 10:10 p.m. Monday on Conestoga Street near Girard Avenue.
Police arrived to find the victim, Barry Jones, shot twice in the head. They rushed him to Penn Presbyterian Medical Center where he was pronounced dead.
Police say Jones was inside with a female friend when the gunman came into the apartment.
Philadelphia Police Chief Inspector Scott Small said, "The perp was invited in by the 36-year-old female while in the bedroom where the shooting took place."
Police believe the shooter immediately pulled a gun on the female to rob her and Jones intervened, and then the shots rang out.
West Phila man shot & killed after interfering when his friend was robbed in her apartment. Robbery victim knew the suspect. @6abc— Annie McCormick (@6abcAnnie) January 10, 2017
"The perp still robbed the female of her cell phone and 20 dollars and fled down the steps out the door of the property," said Small.
Neighbors describe hearing shots and stayed indoors, a short time later police and medics arrived.
"I noticed my wife was actually laying on the ground, on our floor in between our bed and dresser, and was like 'baby I think I just heard gunshots,'" said Al Smith.
A family member of the robbery victim answered the door on Tuesday, but did not want to talk.
Police say there are real time city cameras in the area and they will be looking at that video. But if you have information you can call 215-686-TIPS and remain anonymous.