A New York City police officer was fatally shot Sunday in the Bronx during a struggle with an armed assailant, police said.

Chief of Department Terence Monahan said Officer Brian Mulkeen, 33, was part of a unit assigned to the area near an apartment complex where gang activity, including shootings, had been reported.

"There is absolutely no worse moment on our job than this," Monahan said at a news conference. "As we stand here this morning, a young man with a bright future who courageously patrolled some of New York City's toughest streets has tragically lost his life. Brian was a great cop, dedicated to keeping this city safe."

Monahan said officers had approached a man for questioning, and when the man fled the officers pursued on foot.

"A violent struggle on the ground began," Monahan said. "On the body-worn camera, Officer Mulkeen can be heard yelling 'He's reaching for it, he's reaching for it.'"

Police officer kills himself: Nine NYPD deaths by suicide this year

Shots rang out, and Monahan said Mulkeen was struck three times, possibly by his own gun. Five officers opened fire, and the suspect was killed. Mulkeen was rushed to a hospital, where he was pronounced dead, Monahan said.

The officer's gun was fired five times, but it was not clear who fired it, Monahan said. A .32 caliber handgun belonging to the suspect was recovered at the scene but had not been fired.

Mulkeen had served almost seven years. He lived with his girlfriend, also a New York City police officer,

"Tonight is a vivid example of the dangers New York City cops face every single day," Monahan said.

Mulkeen was the second police officer to die in the line of duty this year. Detective Brian Simonsen, a 19-year veteran, was accidentally shot by fellow officers in February while responding to a robbery.

Mayor Bill de Blasio ordered all flags in the city lowered to half-staff.

"Last night we lost someone who was by every measure a hero," the mayor said. "Officer Brian Mulkeen dedicated nearly seven years of his life to protecting the city he loved. Please join me in keeping his family, friends and brothers and sisters in uniform in your prayers today."