A man accused of stabbing another man was shot by an off-duty NYPD officer on the Upper West Side Friday morning.

According to the NYPD, the incident began just after 7 a.m. inside a Duane Reade store along Broadway between W. 94th and W. 95th streets.

Police said an off-duty officer was working as a security guard at the store. The NYPD said the officer asked two men inside the store to leave because they were having a dispute.

Once outside, authorities say one of the men stabbed the other. The off-duty officer chased the 42-year-old suspect a block away to Amsterdam Avenue, according to police. The NYPD said the suspect then turned on the officer with the knife. That’s when police say the off-duty officer discharged his weapon, hitting the suspect in the left arm and left leg.

“I heard, 'bang, bang, bang.' I knew those were gunshots. And so then I heard the sirens,” said Upper West Side resident Pamela Rosenblum. “Someone I know in the building looked out and she saw the shooting. She didn’t know it was a cop. She said the person who had the gun had the word security or something on them.”

Police say a knife was recovered at the scene.

The suspect, a 42-year-old man, is in police custody and in stable condition. The stabbing victim, a 66-year-old man, is expected to survive. The off-duty officer was not injured.