The man, wielding a large assault rifle, was shot by officers in Rialto on Monday, police chief Mark Kling said in a press conference.
During the conference on Monday morning, the police chief said: “I want to report a brazen armed assault that occurred against one of our officers today in our secure police compound.
“At 4:27pm, a three-year veteran police officer for Rialto Police was entering the secured parking areas where only police vehicles are located.
“There are two signs on either side of the gate that clearly say ‘please do not enter – police vehicles only'”.
But he said as the gate opened to allow a police car to make its way through, it was followed by a black car unknown to the officer.
Mr Kling said the suspect then immediately exited his vehicle and charged at the officer, who happened to be returning from a food run, with an AR-15-style rifle.
Video footage shows the gunman began running back towards his car before stopping and raising the weapon, pointing at the officer who had just exited the police vehicle.
The suspect was then shot “multiple times” by officers and fell to the ground.
The police chief said the gunman was then handcuffed and taken into custody before being treated by the Rialto Fire paramedics.
READ MORE: New Yorker exposes new pickpocketing scam as crime at ‘all time high’
The suspect’s or the police officers’ names have not yet been released.
San Bernardino County Sherriff’s Department is carrying out an investigation into the circumstances and will assess whether police protocol was followed during the shooting.
It is still unclear whether the rifle was authentic or a replica, and the suspect did not fire the weapon during the exchange.
Mr Kling said: “We do not have a motive, we haven’t been able to talk with him at this point – the suspect is actually in stable condition at a local trauma centre.
“So we’re hoping through our investigation we will be able to determine what his motive is.”
Aerial footage of the scene from NBC showed a weapon resembling a rifle on the ground of the parking lot.
Police continue to investigate the incident but say it was a targeted attack.