Pointing an assault rifle to the ceiling, the masked figure who had entered Joplin Memorial Middle School just before the start of classes fired a single shot and then his rifle jammed.
"I would classify this as a very dangerous situation, a life-threatening situation," said school superintendent Jim Simpson. "This had all the hallmarks of a school shooting.
"We were lucky."
No one was injured, though the 13-year-old student behind the mask pointed the weapon at students, teachers and administrators, authorities said.
Assistant Superintendent Steve Doerr, who happened to be visiting the school, was among the first to encounter the student.
The boy pointed the weapon at two students and a teacher, then told Doerr, "Please don't make me do this."
Doerr responded, "You don't have to do this, there is another way."
The student then fired the shot into the ceiling.
His Mac-90 rifle, a replica of an AK-47 assault rifle, jammed after the first shot, police said. The rifle belonged to his parents, who told police they kept it in a gun safe.
Doerr and Principal Steve Gilbreth persuaded the youth to leave the building. He walked out, followed by Gilbreth, who used his handheld radio to alert police to the boy's location.
Police took him into custody after finding him crouched behind a nearby building. His name was not released because of his age.
The student's backpack contained military manuals, instructions on assembling an improvised explosive device and detailed drawings of the school. The school, which has 750 students, was closed while police and Missouri State Highway Patrol officers searched the building with bomb-sniffing dogs. No explosives were found.
"This was quite well thought-out," Joplin police officer Curt Farmer said. "He had been planning this for a long time."
Lt. Geoff Jones said the boy's motives were unclear. School officials said the student had no major disciplinary problems.
Simpson said police told him the boy had a fascination with the Columbine High School shooting that left 15 people dead near Littleton, Colorado, in 1999. Police declined to comment.
The student was wearing a trench coat like the student gunmen at Columbine and had a mask or hood fashioned out of a white T-shirt with two holes cut out for his eyes, reports AP.
Joplin, which has about 40,900 residents, is in southwest Missouri. It is about 10 miles (16 kilometers) from the small town of Riverton, Kansas, where five high school students were arrested in April and accused of plotting a school rampage.
Schools across the country have been on alert since the recent school shootings. In Pennsylvania, church bells tolled Monday morning in remembrance of the five young Amish girls killed at their one-room schoolhouse one week earlier.