Image copyright Getty Images Image caption Police say a number of students had to be medically evacuated from the school

A gunman who killed four people on Tuesday in rural California fired into an elementary school but was stopped from entering by teachers, police say.

Staff at Rancho Tehama Reserve School went into lockdown, securing school doors after hearing nearby gunshots.

Authorities praised the teachers' actions as "monumental" in saving "countless" lives.

Police confirmed one child was shot at the school after the gunman fired into it. Others were hurt by broken glass.

Police later confronted the gunman in a stolen vehicle, shooting and killing him. He was named locally as 43-year-old Kevin Neal.

It is believed the shooting spree began after a domestic row with the gunman's neighbours in Rancho Tehama, a rural community about 120 miles (195km) from Sacramento, on Tuesday morning.

Police said they believed he went on a "bizarre and murderous rampage" after the dispute escalated and he killed a neighbour.

Officials confirmed the gunman had "prior contacts with law enforcement".

The Tehama district attorney told the Sacramento Bee he was being prosecuted on charges relating to a stabbing and assault in January in an incident involving two of his neighbours.

He had also reportedly been the subject of a domestic violence call on the eve of the gun spree.

'This guy is crazy'

A semi-automatic rifle and two handguns were recovered from one of the crime scenes, police said. At least 10 people were injured in the shootings at multiple locations.

Police said he chose most of the victims at random, and reportedly shot into the school but became frustrated after the teachers locked the doors and left after six minutes.

It is believed the school was alerted after a mother was shot at in her car while driving her children to school. She was reportedly seriously wounded but not killed.

The child who was shot has undergone surgery after being struck in the leg and chest, reports say. Other children at the school were reportedly injured by broken glass, and some were evacuated from the school and transported to hospital by helicopter.

Image copyright Getty Images Image caption Police examine a vehicle that was involved in the string of shootings in Rancho Tehama

"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," Assistant Sheriff Phil Johnston said.

The Redding Record Searchlight newspaper spoke to a man who said he was a neighbour of the gunman.

Brian Flint said his neighbour "has been shooting a lot of bullets lately, hundreds of rounds, large magazines".

"We made it aware [to police] that this guy is crazy and he's been threatening us," he told the newspaper.

Image copyright AFP/GETTY Image caption The rampage is believed to have began at about 08:00 locally

The Associated Press spoke to a woman who identified herself as Neal's mother, who said he had told her: "I'm on a cliff and there's nowhere to go."

She said Neal was in a long-running dispute with neighbours who he believed were cooking methamphetamine.

She added that Neal, who was raised in North Carolina, had been working as a cannabis farmer and had recently married his longtime girlfriend.

His sister, Sheridan Orr, told the Associated Press that she believed her brother was addicted to drugs, and had struggled with mental illness and a violent temper.

"We're stunned and we're appalled that this is a person who has no business with firearms whatsoever," Ms Orr said.

She added that she hopes this attack will "make people realise there must be some gates on people like this from getting guns".

"This is the same story we're hearing more and more."

Police have refused to officially confirm the gunman's identity until all his next-of-kin are notified.

US President Donald Trump was criticised online after he tweeted condolences to the wrong mass shooting.

"May God be with the people of Sutherland Springs, Texas," a post on his account said on Tuesday night, though that shooting happened on 5 November.

The tweet was deleted by Wednesday morning.