All four victims were white men, and one of them was shot sitting in a car. Media in the city named him as Zackary Randalls, a 34-year-old father of two who was on his first day in his new job as a utility worker.

The suspect had indicated on social media that he hated white people and expressed anti-government views, police said.

“He wanted to kill as many people as he could and that’s what he set out to do,” said Mr Dyer.

“This was a random act of violence. These were unprovoked attacks by an individual who was intent on carrying out homicides today.”

Mr Dyer added that Tuesday’s attack “has nothing to do with terrorism in spite of the statements that he [Kori Ali Muhammad] made”.

“He did clarify that the reason he had made that statement was that in the event that anything did happen to him that he was in fact pledging his allegiance to God for protection.”

How Fresno’s Muslim community reacted

The most recent statistics compiled by the University of Southern California’s Center for Religion and Civic Culture showed that Fresno, a city of just over 500,000 people, had a Muslim population of just over 1,800 in 2000.

In a statement on Facebook, the Islamic Cultural Center of Fresno condemned the attack, saying: “The phrase Allahu Akbar, or God is Great, is a prayer of peace for 1.8 billion Muslims around the world.”

The centre’s Imam, Seyed Ali Ghazvini, said Mr Muhammad was not known to them.

“This individual does not represent our faith or our community,” he told the Fresno Bee newspaper. “This individual does not represent your Muslim neighbour, your Muslim classmate or your co-worker. The Muslim community in the Valley are working hard for the well-being of our society and country.”

The shooting began around 10:45 local time near the headquarters for Catholic Charities.

Witnesses said they saw a man carrying a large handgun, which he reloaded several times between shots.

Mr Muhammad’s father later told the Los Angeles Times that his son believed he was part of an ongoing war between whites and blacks and that “a battle was about to take place”. He went by the nickname Black Jesus.

The latest shooting is also likely to reignite fresh debates about gun control in the US. More than 30,000 people are killed by gun violence across the country each year.