A man who shot and killed three people set out to kill as many white people as he could, police have said.

Kori Ali Muhammad, 39, shouted "Allahu Akbar" ("God is Great") during his arrest in Fresno, California, after he fired 16 rounds in less than two minutes at three men he had singled out at random.

Fresno police chief Jerry Dyer said the shootings had "nothing to do with terrorism in spite of the statement he made."

"This is solely based on race," he added.

Kori Ali Muhammad shouted 'Allahu Akbar' during his arrest before telling police: 'I did it. I shot them' (Fresno Police)

Muhammad first walked up to a lorry and shot a Pacific Gas & Electric employee sitting in the passenger seat.

The driver, who is Latino, sped off to the police station for help, but the shot worker, a 34-year-old white man, died.

Muhammad then shot at another person and missed, police said.

He aimed at a third, killing the 37-year-old on the pavement as he walked with a bag of groceries.

The final victim, 58, was shot dead in the car park of a charity building.

Mr Dyer said Muhammad approached a vehicle in between the shootings, but he spared the lives of two Latino women who were in the car with a child.

"These individuals who were chosen today did not do anything to deserve what they got," Mr Dyer said.

"These were unprovoked attacks by an individual that was intent on carrying out homicides today. He did that."

These individuals who were chosen today did not do anything to deserve what they got (Twitter)

Muhammad is wanted in connection with the fatal shooting of a security guard at a Motel 6 last week.

He told the officers who arrested him he was the man they were looking for, Mr Dyer said, saying: "I did it. I shot them."

On what appeared to be Muhammad's Facebook page, he repeatedly posted "#LetBlackPeopleGo" and encouraged "black warriors" to "mount up". A flurry of posts emerged in the past day.

He wrote that his "kill rate increases tremendously on the other side" and also posted about "white devils".

On several occasions, he wrote updates including the phrase "Allahu Akbar".

Muhammad has a criminal history that includes arrests on weapons, drugs and false imprisonment charges and making terrorist threats.

He had been associated with gangs but he was not a confirmed member, police say.

Muhammad was charged in 2005 with possessing cocaine with intent to distribute, court records show.

Federal prosecutors said at the time that he was also in possession of a 9mm semi-automatic handgun and two rifles after being convicted of a felony.

He claimed insanity and his lawyer requested a psychiatric examination, saying Muhammad "appeared eccentric with some bizarre beliefs".

A psychiatrist who examined Muhammad believed he had psychosis, his lawyer said in the court filing.

He also "suffered auditory hallucinations and had at least two prior mental health hospitalisations", according to court documents.

His lawyer said Muhammad had "paranoia" and thought the justice system and his defence were conspiring against him, court papers said.

He faces four counts of murder and at least two additional charges of assault with a deadly weapon.

Additional reporting by Associated Press