An 18-year-old server at IHOP was able to wrestle a gun away from a man who shot him Tuesday night, according to police and the teen's father.

Sam Swindell, 18, was shot in the hand inside the restaurant, said his father, Scott Swindell, who heard the story from his son. Matthew Sheedy, 19, was jailed after the incident and is facing a charge of aggravated robbery.

Sam Swindell, a senior at Success High School, was covering a shift for someone that night, his father said. Three customers came in around 6 p.m. Scott Swindell said one of the men was Sheedy, who was very agitated and aggressive toward Sam.

Sam Swindell knew one of the customers, who was his coworker, an arrest affidavit filed on Thursday in Travis County says. Pflugerville police said Sheedy knew Sam Swindell through a mutual friend.

Sheedy asked Sam Swindell about buying marijuana and Xanax or if he knew anyone who sold it, according to the affidavit. Sam Swindell said he didn't and Sheedy began cursing and saying he was going to fight him, the affidavit says.

The customers left, and Sam Swindell's coworker called and apologized for Sheedy's behavior, the affidavit says. Sheedy later returned alone and went into the restaurant's men's restroom. Sam Swindell followed him into the restroom and Sheedy began asking him for Xanax, the affidavit says.

When the teen couldn't produce any narcotics, Sheedy displayed a pistol and demanded money, police said. Police said they are not investigating Sam Swindell as a drug dealer or any other drug-related offense.

As Sam Swindell began pulling out his wallet, Sheedy began to rack the pistol back to load a round into its chamber, the affidavit says. When he saw the weapon, Sam Swindell reacted by punching Sheedy in the face, Scott Swindell said. The affidavit says he punched him in the head and face.

"Sam was trying to take control of the situation and get the gun away from him," his father said.

The gun went off, and a bullet injured Sam's hand, his father said. Sam was then able to wrestle the gun away and point it back at Sheedy, who took off, his father said.

Police said they caught Sheedy just outside the restaurant. They found a bullet hole in the wall under a sink in the men's restroom and a bullet fragment in the right sink, the affidavit says. Bullet casings were also found in the hallway outside the restroom.

"The response time was incredibly fast. ... They were able to apprehend the suspect just as he left the building," Pflugerville Sgt. Jared Bruno said.

Sam is "pretty shaken up," but doctors expect his hand to fully recover, his dad said.

"We're heartbroken that our son went through something like this, but we're so thankful he's going to be OK," Scott Swindell said.

Sheedy is also facing a marijuana possession charge, and police said other charges could be forthcoming.