Teacher Ryan Heber and a campus supervisor talked a gunman into putting down his weapon after he had shot and injured one pupil at Taft Union High School.
Police said the gunman had enough ammunition to kill many people.
The injured student was taken to hospital in an air ambulance and is in a critical condition.
The drama started after 09:00 local time 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.
Ryan Heber, who had been grazed by a pellet, then intervened.
He and another school official who entered the classroom are 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.
“They talked him into putting that shotgun down. He in fact told the teacher, <<I don’t want to shoot you>>, and named the person that he wanted to shoot,” Kern County Sheriff Donny Youngblood said.
“The heroics of these two people goes without saying. They could have just as easily… tried to get out of the classroom and left students, and they didn’t,” he added.
Parents of pupils said the suspect had been suspended last year from the school 120 miles (190 km) north of Los Angeles.
Deputies from the local sheriff”s office and town officials conducted a search of the school and its grounds to make sure no-one else was involved and all other students were safe.
The shooting comes four weeks after a gunman killed 26 pupils and staff at the Sandy Hook Elementary School in Connecticut.
That incident has provoked a nationwide debate about gun laws in the US. Vice-President Joe Biden has said his task force on gun control will make its recommendations to President Barack Obama as early as Tuesday.
Taft Union High School will be closed for classes on Friday, but will have counselors on campus to talk to worried students.
Former pupils of the school include the distinguished US Air Force pilot, General Gordon Graham, the American football player Russell Letlow and the television actress Jeanne Cooper.
Jvl5Z7XrUDEThe US House Ethics Committee has voted to release its report on former Republican Representative…
ABC News has agreed to pay $15 million to President-elect Donald Trump to settle a…
South Korea’s parliament has voted to impeach President Yoon Suk Yeol over his failed attempt…
Israeli war planes have carried out more than 100 air strikes in Syria on December…
President-elect Donald Trump has threatened to impose 100% tariffs on the BRICS countries if they…
Syrian troops have withdrawn from the city of Aleppo following an offensive by rebels opposed…