A crazed gunman — screaming “Allahu Akbar” — killed three people in downtown Fresno, California, on Tuesday and might have gunned down a fourth victim last week, officials said.

The suspect in custody was identified as Kori Ali Muhammad, 39, who has told police he hates white people, Police Chief Jerry Dyer said. All the victims were white males.

Moments before he was grabbed by officers, Muhammad screamed the Arabic phrase for “God is great,” said cops in Fresno — in the heart of rural central California, about 170 miles south of San Francisco.

“Immediately upon the individual seeing the officer he literally dove onto the ground and was taken into custody and as he was taken into custody he yelled out ‘Allahu Akhbar,’ ” Dyer said.

Muhammad also goes by the nickname “Black Jesus,” according to Fox affiliate KMPH.

“What we know is that this was a random act of violence,” Dyer said. “There is every reason to believe he acted alone.”

Cops have gone over the suspect’s social media accounts and might have found his motive.

“We know that he has some posts that says that he does not like white people,” Dyer said. “Also on that post, he has express some anti-government sentiments. Fortunately he is in custody.”

Muhammad is also suspected of killing unarmed security guard Carl Williams, 25, at Motel 6 on Thursday, officials said.

Cops said they suspected Muhammad for the Motel 6 killing almost immediately based on security footage.

Officers searched the area for days but didn’t name publicly name Muhammad as a suspect until Tuesday morning.

Sayed Ali Ghazvini, imam of the Islamic Cultural Center of Fresno, said Muhammad isn’t a member of his congregation and didn’t recognize him at all.

“We’re kind of shocked and surprised for what happened,” Ghazvini said. “We are very sorry for this to happen. We offer condolences for the victims, we pray for the victims and their families.”

The carnage Tuesday began at about 10:45 a.m. PDT when the gunman opened fire on a passenger seated in a PG&E utility truck in the 300 block of North Van Ness Avenue, Dyer said.

The gunman then walked a short distance to the corner of Mildreda and Fulton streets where he gunned down a pedestrian, Dyer said.

Then after reloading his revolver, the killer showed up at the at the parking lot of Catholic Charities at 149 N. Fulton St. where he murdered his third victim of the day, according to Dyer.

All three shootings happened in about a minute.

Spent .357-caliber rounds were found at the crime scenes.

Muhammad allegedly threw his gun away just before his arrest on Tuesday, Dyer said. Police dogs were sniffing around downtown Fresno looking for the murder weapon.

The ATF and FBI are going to be brought into the into the probe.

“Too early to say to say whether this involves terrorism,” Dyer said.

Muhammad has previous arrests for drug, weapons and making terrorist threats, according to police.

A spokeswoman for Catholic Charities said she doesn’t believe the gunman was specifically targeting that charity.

“At this point we don’t believe that they (the shooter) were clients or anybody that had an affiliation with Catholic Charities,” said Ashlee Wolf, a spokeswoman for Catholic Charities. “So right now, we are just working with the Fresno Police Department to get them as much information as they need.”

Utility giant PG&E said the first victim of today’s shootings was an employee.

“Our hearts are very heavy today, as we have lost a member of our PG&E family. Our thoughts and prayers are with the family of our employee, and all those impacted by this tragic event,” the utility said in a statement.

“We are cooperating with law enforcement authorities as they investigate the incident. This loss is particularly difficult for our employees who live and work in the Fresno area. We are sending additional resources to support our employees in the Central Valley.”