A masked gunman attempting to rob a store in West Philadelphia was fatally shot by the owner Thursday night, police said.

The alleged gunman, an unidentified man in his mid-20s, entered the store at the corner of Wyalusing Avenue and Conestoga Street just before 9 p.m. and tried to rob the 53-year-old store owner, who was in a small booth behind the counter, said Chief Inspector Scott Small.

The store owner got out a pistol and shot the perpetrator in the abdomen, Small said. The incident was recorded by in-store surveillance video.

The gunman then fled outside and fired at least three shots at the owner, who had run outside after him, Small said. The gunman got into a Pontiac sedan and tried to drive away but drove up onto a curb in the 500 block of North 54th Street.

Police found him unconscious in the driver seat, still wearing the mask and with a pistol in his lap, Small said. The officers broke the windows of the Pontiac to get him out and rushed him to Penn Presbyterian Medical Center, where he was pronounced dead at 11 p.m.

The owner and two employees inside the store were not hurt.