A 15-year-old pupil from Eldorado Park, Johannesburg was arrested on Thursday after he allegedly pulled out a toy gun, pointed it at his teacher and threatened to shoot.
Gauteng education department spokesperson Steve Mabona said the pupil was later released into his parents' custody.
The teen cannot be identified because he is a minor.
According to police spokesperson Captain Thinandavha Lufhugu, a teacher confronted the Grade 8 pupil on Tuesday for wearing a beanie at school.
"On Wednesday, he wore the beanie again and the teacher confronted him again, asking him to take it off. Instead of taking it off, he pulled out a gun...." Lufhugu said.
Lufhugu added that it was later discovered that the firearm was a toy gun.
"He has been charged with pointing a firearm and possession of a dangerous weapon. It's a toy gun but it uses pellets, which can cause harm," Lufhugu added.
According to Mabona, a disciplinary hearing is expected to take place on Thursday evening.
The pupil is also expected to appear in the Kliptown Magistrate's Court on Friday in connection with the criminal charges.
Kliptown police have confirmed the court appearance.
"We wish to reiterate that, school-based violence and other related misdemeanours will be expedited and as such, we are indebted to the SGB (School Governing Body) for their swift action.
"We have adopted a zero-nonsense-tolerance approach towards delinquents and will demonstrate no mercy towards lawlessness in and around our schools," Gauteng Education MEC Panyaza Lesufi added.