A suspect in an illegal gun buy operation and a bystander were both shot by an undercover NYPD officer in Mount Vernon on Friday afternoon after the suspect robbed the officer, police said.

Officials said the shooting happened about 4 p.m. Friday when the undercover NYPD officer was working on an ongoing investigation into the sale of illegal guns.

The NYPD said in a statement that the undercover officer was meeting with a suspect who said he had guns for sale. The suspect and officer met in the Bronx, and the suspect told the officer to drive to Mount Vernon. Once there, a second suspect, a 37-year-old man, got into the backseat of the car. That suspect pointed a gun at the officer's head and demanded money, police said.

photosRecent NYC mug shotsSee alsoMajor NYC crime

The officer handed him the money, and the second suspect attempted to flee. After signaling backup, the officer got out of the car and tried to stop him, and the suspect pointed his gun toward the officer, police said.

advertisement | advertise on newsday

The officer fired, hitting the suspect three times in the torso, police said. During the melee, a 63-year-old bystander, who was standing behind the suspect, was also shot in the torso. The bystander and suspect were both taken to Jacobi Medical Center, where police said the bystander was listed in serious condition. Police did not list the condition of the suspect, and did not identify either the suspect, the bystander, or the officer.

The officer was not hurt.

Police said they recovered the undercover officer's "buy" money, which he had in order to buy the illegal guns, and a replica of a large caliber gun from the second suspect. The first suspect fled the scene, and the investigation is ongoing, police said.

Mount Vernon Police Commissioner Terrence Raynor said earlier Friday that "things went awry" amid an undercover operation,and that several gunshots were fired in a residential neighborhood near Beekman Avenue and Pease Street.

With AP