The man who was shot by police during a confrontation in Brooklyn on Sunday has been charged in the case, the NYPD said.

Paul Mathurin, 31, is charged with criminal possession of a controlled substance, criminal possession of a weapon, reckless endangerment and menacing, according to police.

It was around 7:15 a.m. on Sunday when police said they were notified via ShotSpotter technology of gunshots near Rogers and Sterling avenues in Prospect-Lefferts Gardens. ShotSpotter uses sensors to detect gunshots in parts of the city.

Police said they also received calls about a shot fired. 

When officers arrived, police said they saw Mathurin armed with a gun in the middle of the street.

Police said witnesses told them that Mathurin was showing his gun, screaming and acting in a menacing manner. When the officers approached him and asked him to stop, he did not, they said.

Three officers then opened fire, striking Mathurin once in the right hip, police said.

Mathurin was taken to Kings County Hospital Center in stable condition, according to the NYPD.

Police said a 9-mm Taurus handgun was recovered at the scene.