A plainclothes NYPD detective shot a 20-year-old man who attempted to rob him Sunday night in Brooklyn, police said.

The detective was in the area investigating an earlier robbery at 6:40 p.m. with two other detectives, one wearing a reflective NYPD vest and the other in plainclothes. The group was approached by three men, one of whom “displayed a firearm,” according to Newsday, and the unidentified officer fired his weapon, striking the gunman in the torso.

Assistant Chief Patrick Conry, chief of Brooklyn detectives, said it wasn’t clear if the man’s gun was real or fake.

The suspect was treated at Kings County Hospital Center and is in stable condition, Newsday reported. The detective was treated for tinnitus at New York Methodist Hospital.

Cops arrested a 16-year-old member of the group at the scene, but the third man was not in police custody as of Sunday night, according to The New York Times.

“It’s very early on in the investigation,” Conry told the Times. “We don’t know if the males that were apprehended here are connected with the initial robbery complaint.”