A West Virginia high school went through an emergency situation when a14-year-old boy allegedly held 29 students and a teacher at gunpoint on Tuesday afternoon before releasing them and surrendering after negotiations. No injuries were reported.

The student took a pistol into a second-floor classroom Tuesday afternoon at Philip Barbour High School in the north-central part of the state, State Police Lt. Michael Baylous said in a statement, according to U.S. News.

"After initial negotiations, the suspect agreed to release all of the hostages. ... After further negotiations, the suspect put the gun down and surrendered to law enforcement without further incident," police said, according to ABC News.

The incident happened in the small town of Philippi, home to about 3,000 residents and located about 115 miles south of Pittsburgh, Pa. Authorities said the episode began after 1 p.m. and police had the situation under control by about 3:30 p.m.

Barbour County Schools Superintendent Jeffrey Woofter credited the teacher for maintaining control when classes were about to change and praised the Philippi police chief for talking the suspect into giving up. Woofter said the teacher talked the boy into not allowing the next group of students to enter the classroom.

"The teacher did a miraculous job, calming the student, maintaining order in the class," Woofter said, declining to identify the teacher by name, reports Today Online.

Woofter said Philippi Police Chief Jeff Walters negotiated the release of the students from the classroom and eventually got the suspect to surrender a few hours after the ordeal began.

Walters "did an awesome job negotiating with this very troubled young man," Woofter said, according to Denver Post.

Kayla Smith, a 17-year-old senior at the school, said initially no one in her classroom (in another area of the school) took the "code red" warning announcement seriously. "Then we all held hands and said a prayer," she said, according to the Denver Post.

Barbour County Prosecutor Leckta Poling plans to pursue unspecified charges against the suspect, who was taken to a hospital for evaluation. Poling said that because the case involves a juvenile, the court process would be closed. Police haven't identified the student, reports U.S. News.