An armed woman opened fire at a robber who was attacking her but accidentally struck a security guard nearby, according to investigators.

The incident occurred at the Save-a-Lot store on the 5800 block of Pulaski Avenue around 6 a.m. Monday. A 51-year-old woman told police she was trying to walk inside the store but a man, later identified as Brian Prater, 45, was blocking the entrance. The woman said she then called store security and dialed 911 for help. After what the woman described as “several verbal encounters,” Prater charged at her with a large stick and tried to strike her, police said. He also allegedly threw hot coffee on her.

The woman, who happened to be armed, pulled out her revolver and fired two shots at Prater, according to officials. Police say the first shot ricocheted off the ground and struck a 24-year-old security guard who was nearby in his right shin. Prater then fled the scene with the woman’s purse and cellphone, according to investigators.

Responding police officers later found Prater on Rittenhouse Street, officials said. He still had his stick and the woman’s purse and he was taken into custody without incident, according to investigators. Prater, who was not injured during the ordeal, is charged with robbery and theft unlawful taking.

The injured security guard was taken to the hospital for treatment and is expected to recover. Police say the woman has a valid permit to carry but they are still investigating the incident.

“We don’t want people to just get themselves in situations where they can avoid the escalation to the point where someone is shot,” said Philadelphia Police Captain Malachi Jones. “We’d rather them take evasive action when they can to avoid this from happening.”

The woman's son told NBC10 she's the owner of a daycare. He also said he's glad his mother fought back.

"A gun, a taser, a stick, something," he said. "If it has to be a gun it has to be a gun. If you have to use it, use it."