BROOKLYN - NYPD officials say a man with a gun was fatally shot by police outside of an Brooklyn housing project Sunday morning.

Authorities say they got several 911 calls about an emotionally disturbed person and an armed robbery at the Cooper Park Houses. Officers arrived at the scene around 7:45 a.m.

The NYPD says the man exchanged fire with police. They say he fired five times and officers returned fire at least 12 times.

The man, who was in his 40s, was pronounced dead at Woodhull Hospital.

Officials say a .40-caliber semiautomatic handgun was recovered at the scene.

The two officers involved in the incident were taken to Elmhurst Hospital for observation.