The teen, Joseph Williams, has since been arrested.
Police said Williams was trying to steal the snack cakes from Happy Jacks in the 1600 block of North Myrtle Avenue in Northwest Jacksonville just after 4 p.m. Thursday.
Police said the store clerk then displayed a handgun and chased Williams out of the store. Police said the clerk caught Williams outside the store and they got into a struggle.
The clerk had the gun in his right hand and told Williams to stop resisting, police said. They said the clerk told them that Williams looked at his gun as if he was going to try and grab it, so he struck him in the head to stop him.
The gun accidentally fired, and Williams was able to flee the scene, police said. A K-9 tracked a blood trail several blocks away, but police said they were not able to find Williams.
At 9 p.m., Williams walked into a local hospital for treatment for a gunshot wound to his arm, police said. They said Williams admitted to being in a struggle with the store clerk. He was then arrested.
MSNBC: Police: Teen shot in Twinkies theft at Happy Jacks