(CNN) - A gunman killed four people in a remote Northern California community on Tuesday morning, but a much bigger death toll was averted when the killer was unable to break into an elementary school.
The staff at tiny Rancho Tehama Elementary School west of Corning moved quickly when they heard gunfire nearby just before classes were set to begin, Tehama County Assistant Sheriff Phil Johnston said.
Doors were locked and students dashed inside and hit the floors underneath desks and tables.
The shooter, who was killed by police at another site, rammed a stolen pickup through the school's locked gate, walked into the schoolyard, and fired his rifle through windows and walls.
He tried doors, but the buildings at the Rancho Tehama Reserve school were secure. Only an outside bathroom was open, but the gunman found no one there.
After about six minutes, he left, apparently frustrated.
The school district said a student was wounded by gunfire and was in stable condition. Others were hurt by flying glass.
'Could have been so much worse'
"This individual shooter was bent on engaging and killing people at random. I have to say this incident, as tragic and as bad as it is, could have been so much worse," Johnston said, applauding the quick thinking of the school staff.
The gunfire that triggered the alert at the school came when the shooter fired from his vehicle into others while on his way to the school, about 2 miles from his home.
The gunman's precise motives were unclear, but a dispute with a neighbor who was found dead Tuesday may have sparked the rampage in which there were seven shooting scenes.
"This is an individual who armed himself, I think with the motive of getting even with his neighbors and when it went that far (that someone was killed) he just went on a rampage," Johnston said.
The killer apparently chose most of his victims at random, sometimes firing at passing motorists, homes and also gunning down someone after he purposely crashed into another car.
At least 10 people were wounded or hurt in the string of shootings in Rancho Tehama, about 125 northwest of Sacramento.
The gunman had a tactical vest with extra magazines for his guns, Johnston said, who viewed surveillance video of the shooting.
The wounded victims from the spree included a mother who was driving her children to school when the attacker opened fire on them "without provocation or warning," the assistant sheriff said.
The woman was being treated for life-threatening injuries. A child who was in the vehicle was not seriously wounded, according to Johnston.
A visibly shaken Johnston told reporters earlier: "This is a sad day for us here in Tehama County."
Mom raced back to school to warn people
A fearless mom may have also helped warn staff at the school about the danger.
Sara Gonzalez told CNN she had dropped her daughter off at the school when the gunman attempted to shoot her when their vehicles passed. She thinks the gunman's windshield stopped the bullet.
She turned her vehicle around.
"I went to my daughter's school and started honking, making people know what was going on," she said.
Gonzalez said the gunman fired at her as she tried to get out to get her girl. She saw the man's face but he said nothing.
Jessie Sanders told CNN affiliate KCRA he tried to draw the gunman's attention away from the school.
He said he ran over to the school when he heard the crack of the semi-automatic rifle.
"When I get there, the dude was shooting through the windows," he told the Sacramento-based station. "And I said, 'Hey why don't you shoot this way instead.' "
Sanders said a bullet grazed his right forearm.
In the school the children were trying to stay low.
Gonzalez's daughter, Arianna Ibarra, was inside on the floor with her fourth-grade class.
"Our teacher told us to go under our desk and keep flat in case he comes inside," Arianna said.
The teacher blocked the door with a computer, the 10-year-old said.
The gunman shot at other classrooms, but not hers. When he left, Gonzalez went inside.
"All the kids were pretty calm, laying on the floor. Some were a little distraught, but they were OK," she said.
Known to law enforcement
Johnston said the gunman had "prior contacts with law enforcement." In January the man was arrested on suspicion of assault with a deadly weapon in a case that involved the neighbor who died Tuesday, Johnston said.
Johnston added that the woman had a restraining order against the shooter.
It was unclear whether the gunman went to the school looking for someone he knew.
"We have not connected him with any one person in the school," Johnston said.
Some students were transported to hospitals by helicopter, and others were moved to a safe location in a school bus, the assistant sheriff said. The children were later reunited with their parents.
Three children and an adult were being treated at Enloe Medical Center in Chico, officials said. Their conditions were not available.
"School staff is commended for their courageous and professional response to this terrible incident. The school was able to go on lockdown very quickly and effectively, which prevented any further injury or violence," the school district said in a statement.
The school is closed and will need repairs, the district said.
'A mass murderer really'
A semi-automatic rifle and two handguns believed to be used by the gunman have been recovered, according to Johnston. There is another gun that police have yet to recover in one of the stolen vehicles.
Johnston complimented the officers who stopped the gunman.
"I have to tell you I am personally grateful to the men who engaged this suspect," Johnston said.
"It's a tragic event, but I am personally grateful for engaging such a terrible ... a mass murderer really. That's what he is."
The FBI, the Bureau of Alcohol, Tobacco, Firearms and Explosives and California Highway Patrol have joined the investigation.
Vice president and governor send condolences
Gov. Jerry Brown and wife Anne were "saddened to hear about today's violence in Tehama County, which shockingly involved schoolchildren," the governor said in a statement. "We offer our condolences to the families who lost loved ones and unite with all Californians in grief."
On Twitter, Vice President Mike Pence wrote: "Saddened to hear of the shooting in N. California, the loss of life & injuries, including innocent children. We commend the effort of courageous law enforcement. We'll continue to monitor the situation & provide federal support, as we pray for comfort & healing for all impacted."
And Sen. Kamala Harris tweeted: ""Heartbroken by the news of a shooting at an elementary school in Rancho Tehama. Grateful to the officers and first responders on the scene.
- Umatilla County deputy apologizes for tasing trooper, buys him cake
- New housing development proposed in Richland
- New men's homeless shelter being built in Pasco
- Yakima teen arrested for allegedly raping jogger on the Greenway may be tried as an adult
- Lawmaker placed on paid leave after sexual misconduct complaints resurface