NEW YORK (AP) - A police officer's craving for cake batter ice cream put him and his colleagues in the right place to take action when a loaded gun fell out of a man's shorts at a Baskin-Robbins shop in New York City.

Police say three officers were at the shop in Coney Island, Brooklyn while on-duty Saturday when Emmanuel Lovett walked in, tugged his denim shorts and dropped a pistol to the floor.

The officers swarmed and arrested the 33-year-old man. Police say his robbery record prohibited him from having a gun. He's charged with criminal possession of a firearm.

Lovett is jailed on $7,500 bail. He's due in court Friday. A message seeking comment was left with his lawyer.

The NYPD acknowledged the oddity of the ice cream-induced arrest, tweeting : "Seriously, this actually happened."

Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.