Charlie Decker, a Maine high school senior, is called to a meeting with his principal about a previous incident in which he struck his chemistry teacher with a pipe wrench, leading to the teacher's hospitalization and Charlie's suspension. Charlie then subjects the principal to a series of insulting remarks, resulting in his expulsion. Charlie storms out of the office and retrieves a pistol from his locker, then sets the contents of his locker on fire. He then returns to his classroom and fatally shoots his algebra teacher, Miss Jean Underwood. The fire triggers an alarm, but Charlie forces his classmates to stay in the room, killing a history teacher, Mr. Peter Vance, when he attempts to enter. As the other students and teachers evacuate the school, the police and media arrive at the scene.
Over the following four hours, Charlie toys with various authority figures who attempt to negotiate with him, including the principal, the school psychologist, and the local police chief. Charlie gives them certain commands, threatening to kill students if they do not comply. Charlie also admits to his hostages that he does not know what has compelled him to commit his deeds, believing he will regret them when the situation is over. As his fellow students start identifying with Charlie, he unwittingly turns his class into a sort of psychotherapy group, causing his schoolmates to semi-voluntarily tell embarrassing secrets regarding themselves and each other.
Interspersed throughout are narrative flashbacks to Charlie's troubled childhood, particularly his tumultuous relationship with his abusive father Carl. Several notable incidents include a violent disagreement between two female students and a police sniper's attempt to shoot Charlie through the heart. However, Charlie survives due to the bullet's striking his locker's combination lock, which he had earlier placed in the breast pocket of his shirt.
Charlie finally comes to the realization that only one student is really being held against his will: a seeming "Big Man On Campus" named Ted Jones, who is harboring his own secrets. Ted realizes this and attempts to escape the classroom, but the other students brutally assault him, driving him into a battered catatonic state. At 1:00 p.m., Charlie releases the students, but Ted is unable to move under his own power and remains. When the police chief enters the classroom, the now-unarmed Charlie moves as if to shoot him, attempting suicide by cop. The chief shoots Charlie, but he survives and is found not guilty by reason of insanity and committed to a psychiatric hospital in Augusta, Maine until he can answer for his actions.
The final chapters contain an inter-office memo concerning Ted's treatment and prognosis at the hospital where he is now a patient, and a letter from one of Charlie's friends describing assorted developments in the students' lives during the months following this incident. The story ends with Charlie addressing the reader: "That's the end. I have to turn off the light now. Good night."