An armed suspect was shot and wounded in the leg after exchanging gunfire with three plainclothes NYPD detectives in Brooklyn on Friday night, police said.

​Kowon Davis, 44, from the Bronx, was arrested and charged with criminal possession of a weapon and menacing a police officer, the NYPD said.

The detectives, from the Brooklyn North Gang Squad, were on patrol when they observed the man exit a black Lexus sedan with a firearm in his hand, the NYPD said. He approached a large group of people gathered outside a home on Howard Avenue, police said.

The detectives then exited their unmarked police vehicle, commanding, “Police, don’t move,” police said. The suspect turned toward the detectives and fired his weapon, police said. An exchange of gunfire between the suspect and the detectives ensued, police said.

The suspect fled on foot, but he was taken into custody less than one block away on Sutter Avenue, police said.

The three detectives were not harmed by any bullets, and they were taken to Jamaica Hospital Medical Center in Queens for observation. The suspect was taken to The Brookdale University Hospital and Medical Center in Brooklyn and is in stable condition, police said.