An Alabama substitute teacher was detained after a gun in his pocket allegedly discharged inside a classroom of first-graders on Friday.

One student at Blountsville Elementary School was reportedly struck by a fragment and then checked out by a school nurse after the firearm of Henry Rex Weaver, the teacher, accidentally discharged.

FBI AGENT ACCIDENTALLY FIRES GUN WHILE DANCING AT A DENVER NIGHTCLUB

Authorities told AL.com that the teacher had the gun in his pocket when the incident occurred. Students were present in the class.

“It (the sound) alerted administrators,” Blount County Sheriff Mark Moon told the outlet. “He was detained until we could get him in our jail.”

Weaver was charged with reckless endangerment, third-degree aggravated assault and possession of a firearm on school grounds, authorities said. An investigation is underway.

CLICK HERE TO GET THE FOX NEWS APP

“Obviously I’m concerned about a substitute teacher bring a gun to school,’’ the sheriff added, “and what we can do to prevent that in the future.”