San Bernardino: A teacher and an eight-year-old boy were shot and killed Monday morning at an elementary school in San Bernardino after the teacher's husband opened fire inside a special needs classroom before turning the gun on himself, police said.

Cedric Anderson, 53, of Riverside, entered a classroom at North Park Elementary School and opened fire on his wife, Karen Elaine Smith, about 10.30am before taking his own life, according to San Bernardino Police Chief Jarrod Burguan.

Two students standing behind Smith were also shot, police said. The boy, identified as Jonathan Martinez, was airlifted to Loma Linda Medical Centre, where he was later pronounced dead. A nine-year-old student who was wounded remains hospitalised in stable condition, Burguan said.

The shooting occurred in a special education classroom for students with intellectual disabilities, said San Bernardino Unified School District spokeswoman Maria Garcia. There were 15 students from the first through fourth grades in the room, and two adult aides, Burguan said.