GARDEN CITY, N.Y. (AP) — No criminal charges will be filed in a friendly fire shooting that killed a federal agent after he tried to intervene in a pharmacy robbery on Dec. 31, the Nassau County district attorney said Monday.

The district attorney, Kathleen M. Rice, said the retired Nassau police lieutenant who shot the off-duty senior special agent, John Capano of the Bureau of Alcohol, Tobacco, Firearms and Explosives, “clearly did not enter this situation with the intent to use deadly physical force.”

“He resorted to it,” her report said, “only when he perceived that his own life was in danger.”

The retired lieutenant, Christopher Geraghty, and another bystander, an off-duty New York City police officer named Joseph Arbia, were justified when they used deadly force, Ms. Rice said.

The men were in a deli in Seaford, about 25 miles east of the city, when they were alerted to a robbery at a nearby pharmacy. When they arrived there, they saw Agent Capano, 51, and the robbery suspect wrestling for a gun, which turned out to be Agent Capano’s.