A witness speaking to CBS said he heard up to 30 gunshots from what sounded like “a semi-automatic weapon”.

He said he first heard about a dozen shots, then a pause, then another possibly dozen shots.

The man, who is retired and was eating lunch at home, said he called 911 and that police arrived within “five to 10 minutes”.

Imam Taha Hassane, director of the Islamic Center of San Diego, said at a news conference: “It is extremely outrageous to target a place of worship.”

The facility “is a house of worship, not a battlefield”, he added.

The Muslim community is currently preparing for one of its holiest seasons and its biggest feasts.

It’s days before Eid al-Adha, or the Festival of Sacrifice, which commemorates the obedience of Prophet Ibrahim.

California Governor Gavin Newsom released a statement that he was “horrified by today’s violent attack” at the centre, “where families and children gather, and neighbors worship in peace and fellowship”.

The state “will not tolerate acts of terror or intimidation against communities of faith”, Newsom added.

Asked about the shooting on Monday, US President Donald Trump called it a “terrible situation”.

“I’ve been given some early updates but we’re going to be going back and looking at it very strongly,” he said during an unrelated White House event.