Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A gunman in a rural part of Northern California killed four people and targeted an elementary school but was thwarted by a lockdown procedure, before continuing the rampage and later being killed by police, authorities said.

No children were killed in the shooting spree that began at shortly before 8 a.m. PT in the community of Rancho Tehama Reserve, about 130 miles north of Sacramento, Tehama County Assistant Sheriff Phil Johnston said.

Family members identified the shooter as Kevin Neal, according to NBC News affiliate KCRA 3.

The rampage could have been worse, Johnston said, had not the staff at the school heard gunshots around a quarter-mile away and initiated a lockdown.

"The shooter literally took his vehicle and rammed their fence and gate, entered the grounds on foot with a semiautomatic rifle," Johnston said at a Tuesday afternoon news conference.

"It appears that because he couldn't make access to any of the rooms — they were locked — that he gave it up and re-entered the vehicle and then went on his killing spree and took it to the streets of Rancho Tehama,” Johnston said. "So I really want to say that the quick action of those school officials, there is no doubt in my mind based on the video that I saw, saved countless lives and children."

One child was wounded at the school and another child being driven to school was struck after Neal fired into a vehicle driven by a woman who was also wounded, Johnston said.

Kevin Neal, suspect in California shooting. Tehama County

Parent Coy Ferreira was among those who took shelter in a room at the school after the gunfire began, and described holding the door shut and students taking cover underneath desks.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

“I wasn't sure if the door was locked or not, and during that time of me going 10 steps to the door, a couple bullets struck one of the students that was underneath a desk,” Ferreira told NBC News in a phone interview.

Neal was later spotted chasing a vehicle and firing at it. He then shot at police, police rammed the gunman’s vehicle and ran it off the road, and Neal was killed by officers, Johnston said. No police officers were injured, he said.

Neal was charged with assault with a deadly weapon against a woman in January, and that woman is among the four people killed Tuesday, Johnston said.

A semi-automatic rifle and two handguns were recovered after the shooting spree was over, Johnston said.

Brian Flint told The Record Searchlight newspaper in the city of Redding that Neal was his neighbor, whom he knows only as Kevin, and that Neal's roommate was among the victims. He said Neal also stole his truck.

"The crazy thing is that the neighbor has been shooting a lot of bullets lately, hundreds of rounds, large magazines," Flint said. "We made it aware that this guy is crazy, and he's been threatening us."

Investigators view a pickup truck involved in a deadly shooting at the Rancho Tehama Reserve on Nov. 14, 2017 near Corning, Calif. Rich Pedroncelli / AP

Salvador Tello said Neal fired at a truck in front of him as he was dropping off his three children. Tello said he was about three blocks from the school when bullets made "big holes" in the truck in front of him.

He said he forced his children to duck down and slammed his truck into reverse and headed to the children's grandmother's house.

"I put my kids down and put my truck in reverse and went out," he said. "I don't believe it because I wake up, take my kids, feed them cereal and put them in the truck and says, 'Let's go to school like a normal day.'"

On the way, he said, he saw an apparent gunshot victim and police at another scene. Johnston said there were seven crime scenes.

At the school, Neal was wearing “a load bearing vest that you sometimes see soldiers wear that have the clips embedded in the chest," Johnston said. He shot at a number of classrooms, he said.

A motive in the shooting is unclear. It "appears that he chose the school as a random target," and investigators have not connected Neal with anyone at the school, Johnston said.

"This guy was on a killing rampage," Johnston said. "He was driving up and down the street shooting at passers-by and uninvolved residences."

Two women embrace outside Rancho Tehama Elementary School, where a gunman opened fire on Nov. 14, 2017, in Corning, California. Rich Pedroncelli / AP

Johnston added, "This is an individual that armed himself, I think with the motive of getting even with his neighbors."

Two people were found dead at the first shooting scene and another person was killed after Neal rammed his vehicle and fired at the occupants, Johnston said.

A law enforcement officer is seen at one of many crime scenes after a shooting on November 14, 2017, in Rancho Tehama, California. Elijah Nouvelage / AFP - Getty Images

Tiffany Rodgers and her husband were setting up outside their coffee shop, Coffee Addiction, about a mile from the school, when they heard gunfire. "I heard the first 10 rounds. We heard about 20 more rounds," Rodgers, 33, told NBC News in a phone interview from Corning, California.

California Gov. Jerry Brown said he and his wife, Anne, are saddened by the shooting that "shockingly involved schoolchildren."

Brown offered their condolences to the families who lost loved ones and said they are united with all Californians in grief.