Gunfire erupted as soon as they stepped into the tight confines of the shop, Police Commissioner William J. Bratton said. Shards of glass rained to the ground with the shell casings as bullets slammed into the bodies of the three warrant-bearing men who drew their own weapons and fired back. Mr. Mozdir managed to fire at least four shots from his .32-caliber handgun before he collapsed dead on the floor. There were 20 more rounds in his pockets.

Image Charles Mozdir, who was accused of being a child molester, was identified as the man who died in a gun battle with law enforcement.

Amid the gunfire, the street, which often teems with tourists, wealthy homeowners and freewheeling revelers, emptied in the daytime chaos of banging weaponry and flashing lights. It remained roped off hours later.

One of the shots that hit Detective Muniz, a 20-year veteran, would have killed him had the vest he was wearing not stopped its flight, Mr. Bratton later said.

Holding the semipunctured vest up to the cameras at an evening news conference, Mr. Bratton pointed to a spot that covered the detective’s chest and said that the round lodged there could have been fatal. Another shot struck the detective in the stomach, just below the vest. He was being treated at Bellevue Hospital Center, where he was in stable condition.

Patrick Lin and Ryan Westfield, both deputy United States marshals, suffered non-life-threatening injuries, the authorities said. One was shot in the buttocks and the other in the elbow, they said.