NEW YORK – An off-duty federal law enforcement agent who died while confronting a pharmacy robber was picking up his elderly father’s cancer medication, a New York congressman said Sunday.

Veteran agent John Capano, 51, had chased down the suspect inside the store and was trying to subdue him on the ground when he died, said Rep. Peter King, R-N.Y. The robber, who was also shot to death, was identified Sunday by police as James McGoey, 43, of Hampton Bays.

“John was with him on the ground wrestling,” said King, who has spoken with local authorities and Capano’s family. “Next thing you know, shots are fired.”

McGoey went into Charlie’s Family Pharmacy in Seaford, a small shorefront Long Island town, around 2 p.m. on New Year’s Eve, police said. He announced a holdup and was given what he came for: painkillers and money.

Capano, a trained explosives expert who had served in Iraq and Afghanistan, confronted McGoey as he tried to leave the store. Meanwhile, an off-duty NYPD officer and a retired Nassau County police officer who happened to be at a deli next door were alerted that someone was trying to rob the pharmacy, King said.

“This is a horrible confluence of events,” King said. “They both hear this guy saying there’s a robbery going on. They get their guns, they go next door.”

It’s not clear who shot either man. Capano died of a gunshot wound at a hospital. He was a 23-year veteran of the Bureau of Alcohol, Tobacco, Firearms and Explosives who taught U.S. military and local forces in Afghanistan and Iraq how to investigate blasts, said Rory O’Connor, assistant special agent in charge in the ATF’s New York office.

Capano lived in nearby Massapequa and was married with two children. His father, Jimmy Capano, was a retired NYPD detective and the “unofficial mayor” of Merrick Road, the main thoroughfare in town and the street where his son was killed, King said.

“Everybody in Seaford knows the Capanos,” said King, who has lived in the town for 40 years. “They’re good, solid people.”