A 14-year-old boy is in custody after holding 29 students and a teacher hostage at gunpoint in a West Virginia classroom.
The teenager later released them unharmed after police negotiations and surrendered, authorities said.
No injuries were reported.
The student took a pistol into a second-floor classroom on Tuesday afternoon at Philip Barbour High School in the north-central part of the state, State Police Lt. Michael Baylous said in a statement.
It was the ninth day of the new school year in Philippi, a town of 3,000 residents located about 115 miles (185 kilometers) south of Pittsburgh, Pennsylvania. Authorities said the episode lasted two and a half hours.
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.
Mr 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," Mr Woofter said, declining to identify the teacher by name.
Kayla Smith, 17, said initially no one in her classroom in another area of the school took a "code red" warning seriously.
"Then we all held hands and said a prayer," she said.
Mr 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 it began.
Barbour County Prosecutor Leckta Poling said she plans to pursue unspecified charges against the suspect, who was taken to a hospital for evaluation.