The drama started after 09:00 local time (17:00 GMT) when the gunman, also a student, arrived late, armed with a shotgun, at the school in the small town in California's central valley.
Students and staff telephoned police, but before officers could arrive, the suspect had shot at two people in a class in the science block. One shot missed its target.
The teacher, who had been grazed by a pellet, then intervened. He is reported by US media to have warned the suspect that there would be no shooting in his class, at which point the gunman put down his weapon and police officers arrested him.
The teacher wasn't having none of it!!!!!