Louis Leston Anderson, 48, was standing in line to buy a bagel and coffee in the grocer's cafe near Broadway and West 80th Street about 9:45 a.m. when he adjusted a gun in his waistband and accidentally shot his right leg, officials said.
"I just ducked. I had never heard gunfire before. Everybody was surprised, including myself," said Robert Levit, 70, who was in the cafe with his morning's lightly toasted plain bagel with cream cheese.
"I left my bagel in there with all the excitement," said Levit, who's lived nearby for about 20 years.
Anderson dropped his bagel and coffee before fleeing the scene, leaving a trail of blood out of the store, sources and staff said.
Anderson, who's homeless but grew up in East New York, ditched the gun in a plastic bag in Riverside Park near West 79th Street, sources said.
Bloodhounds tracked him to West 80th Street and Riverside, but by then the shooter had managed to get himself to Mount Sinai Roosevelt Hospital, sources said.
Police found Anderson in the hospital and arrested him for reckless endangerment and criminal possession of a weapon, police said Wednesday morning.
He told investigators that he found the gun on the street near the Lincoln Tunnel while going through some trash, sources said.
Anderson hadn't been formally charged as of 11:30 a.m., police said. He's been arrested nine times before, mostly for drug offenses, sources said.
The grocery store, which management said opened in 1934 and serves about 35,000 customers a week, was running as normal though the cafe briefly closed after the shooting.
The cafe reopened about 11:30 a.m. and almost immediately every seat in the place was taken and a long line of eager customers formed at the counter to buy their knishes, strudel and lox.
Zabar's regulars were unsettled when they heard about a shooting in their usually peaceful neighborhood.
"It's very shocking that someone walks around with a gun here. This is one of the safest neighborhoods," said Ricky Mills, 40, who was on her way to get a smoked salmon bagel for breakfast from Zabar's.
"I hope the person learns a lesson. It's just so wrong. It shouldn't be happening," she added.
Zabar's general manager, Scott Goldshine, 56, said that Tuesday's shooting was a first for his staff, but they're all handling it well.
"It's New York. Stuff happens," Goldshine said.