An NYPD plainclothes detective shot and wounded a man in East Harlem Tuesday night after the suspect turned his gun on the detective and his partner, police said.

The two detectives, assigned to the Special Victims Unit, were near East 101st Street and First Avenue at about 8 p.m., when they saw the gunman running south on First Avenue before shooting another man in the torso and leg, police said.

advertisement | advertise on newsday

The shooting victim, 21, then fled north on First Avenue with the suspect, 26, in pursuit, police said. The two detectives confronted the gunman, identified themselves as police officers and told him to drop his weapon, police said.

photosRecent NYC mug shotsDataNYC crime rates

The unidentified suspect pointed the gun at detectives instead, police said. One of the detectives fired two rounds, hitting the suspect in the torso. A .22-caliber semi-automatic pistol was recovered at the scene, police said.

The suspect was taken to Harlem Hospital Center in stable condition, police said. The 21-year-old shooting victim brought himself to Metropolitan Hospital Center and also is listed in stable condition.

Charges are pending, police said.