Police have identified the suspect who was shot and killed by officers in Brooklyn on Thursday after they said he pulled a gun on them.

Kadeem Torres, 17, was fatally shot around 4 p.m. in the backyard of 890 Belmont Ave. after he opened fire on police and led officers on a foot chase, cops said.

Two officers and a sergeant were patrolling the area in their vehicle when they spotted Torres running near the Cypress Hills public housing complex, NYPD Chief of Patrol Terence Monahan said during a Thursday evening news conference. Based on information of a possible retaliatory shooting in the area, the officers began to follow him in their vehicle.

But when the sergeant and one of the officers tried to approach Torres about two blocks from where they first saw him, Monahan said he pulled out a .32 mm revolver and fired at them. Gunfire was exchanged and Torres took off on foot.

One of the officers chased him into the backyard of 890 Belmont Ave., where Torres, who was still armed, was fatally shot, Monahan said. He was pronounced dead at the scene.

Police said the information regarding the possible retaliatory shooting was related to a shooting in the same area over the weekend. 

As the investigation began to unfold, investigators puzzled over why a Brooklyn teenager with no significant criminal history decided to fire on officers.

Two gangs — the “front side Crips” and the back side Crips — have been responsible for a number of shootings in the public housing area and Torres may have had some affiliation with one of the gangs, the officials said.

“Word was out on the street that they were going to retaliate for the shooting,” the official said.

Retired NYPD detective and author Joseph Giacalone said Torres might have acted the way he did because of area gang influence and its macho mentality.

“It is not like he did not know, these guys were in uniform,” Giacalone said. “It is a very strange set of circumstances.”

With Anthony M. DeStefano