Two NYPD officers shot and killed a man who attacked them in the hallway of a Brooklyn apartment complex on Saturday afternoon, police said.

The officers, a man and a woman from the department’s housing bureau, were injured in the attack in Brownsville and were taken to Jamaica Hospital Medical Center, NYPD Chief of Housing James Secreto said in brief remarks Saturday. Both were in stable condition.

The officers, who were in uniform, responded to a 911 call at 1:10 p.m. about a suspicious man in the ninth-floor hall of the Van Dyke development near Sutter Avenue, he said.

“They approached the subject and asked for his identification. Conversation ensued. Next thing you know, there’s a scuffle. . . . The officer removes his metal baton, the subject gets ahold of this baton and starts assaulting the two officers,” Secreto said.

The suspect struck both officers multiple times, he said, leaving a two-inch gash on the male officer’s head.

“Both officers at this time fired at the subject and he was struck several times,” Secreto said.

advertisement | advertise on newsday

The suspect was pronounced dead at the scene.

The investigation is ongoing, Secreto said, adding the suspect’s name would be released later.

Police Commissioner James P. O’Neill visited the two injured officers at the hospital late Saturday afternoon, a police spokesman said. An NYPD sergeant outside the hospital said Mayor Bill de Blasio also visited, but that could not be confirmed.

Van Dyke is one of 15 New York City Housing Authority developments where the mayor’s office is pursuing what it describes as a “21st century” crime reduction approach that goes beyond traditional law enforcement to address topics like lighting and building design.

The program was put in place in 2014 as crime dropped citywide but soared in public housing developments. The 15 developments where the program was enacted accounted for 20 percent of all violent crime in public housing that year, according to a release from the mayor’s office.

Earlier this year, NYPD Officer Peter Liang was convicted of manslaughter in the 2014 stairwell shooting death of Akai Gurley in the Louis H. Pink projects in the nearby East New York neighborhood. Liang was later cleared of manslaughter and given probation by a Brooklyn judge.