It happened around 11am inside a Spring Woods High School classroom while about 25 students were in class.
Police say a 15-year-old freshman was apparently showing off the gun toward the back of the classroom when it went off, sending a bullet through a door and into the hallway.
Authorities say they don't believe the teen intended to hurt anyone, and thankfully, no one was injured.
But Spring Branch ISD Police Chief Chuck Brawner said the situation could have been much worse.
"It could have been very bad, especially in a classroom with 25 students in there and the likelihood of it hitting somebody is greater with number of people in the room. We're just very fortunate," Brawner said.
An officer was inside the school at the time and responded immediately. The 15-year-old student was arrested, taken to the Spring Branch ISD police jail and charged with felony possession of a firearm on school grounds.
Students who were in the classroom at the time met with counselors. Others who weren't certainly were talking about it after school.
"There's actually no excuse for somebody to bring a gun at any time," Spring Woods student Tiffany Sandstrom said.
Others were thankful the situation wasn't as serious as it could've been.
"No one shot it purposefully, but thank God no one got hurt," Spring Woods student Anthony Mendez said.
The student has not been identified because he is a juvenile. The school says it's confident the student brought the gun to school just to show off and they will be speaking with his parents are part of their investigation.
Meanwhile, the school district says it called parents and sent home a letter about the incident.
Stay with Eyewitness News and abc13.com for the latest on this story.