A cop responding to a Brooklyn murder early Monday was wounded in the face when the suspect fired a shotgun before eventually killing himself, NYPD sources said.

Police responding to a 5:57 a.m. 911 call for a shooting found a 41-year-old man dead outside near Hegeman Ave. and Thomas S. Boyland St. from a gunshot wound to the chest. The victim’s name was not immediately released.

About an hour later, the suspect confronted cops in the hallway of an apartment building at the scene and opened fire with a shotgun.

It wasn’t immediately clear if the officer was struck by a direct blast of pellets from the shotgun or hit by fragments, possibly from a ricochet.

The officer was taken to Brookdale University Hospital with injuries not considered life-threatening, sources said.

“I have been briefed on the NYPD officer who was shot in Brooklyn this morning,” Mayor Adams tweeted from Israel, where he is in the middle of a visit. “Praying for the officer’s recovery and we will continue to monitor the situation.”

Adams said his top deputy, First Deputy Mayor Randy Castro, was headed to Brookdale University Hospital.

Meanwhile the gunman retreated further into the building, sparking a standoff that ended about two hours later when the suspect shot himself to death, the sources said.

Several people were brought out of the building by cops after the standoff, including a woman in handcuffs.

This is a developing story. Check back for updates. 

With Theodore Parisienne