Forty-two gunshots — all fired by the New York City police — rang out Tuesday night outside a cellphone store in Queens. The fusillade, which lasted only 11 seconds, left Detective Brian Simonsen dead. His partner, Sgt. Matthew Gorman, was struck in the thigh.

The men had been responding to a report of an armed robbery. As they retreated from the store, they were shot by their fellow officers.

Last night, the authorities were still trying to piece together exactly what happened.

Police Commissioner James P. O’Neill called the incident an “absolutely tragic case of friendly fire.” Chief of Department Terence A. Monahan said, “This is the worst thing that we go through as a department.”

New York City police officers are rarely killed by friendly fire — the last such incident occurred in 2009. These deaths are rare, in part, because of the extensive training the police undergo, retired police officials said.

“The paradox of policing is that you’re always preparing for this, but you’re never ready for it,” said Eugene O’Donnell, a retired New York police officer who teaches at John Jay College of Criminal Justice in Manhattan.