Adam Powell, 41, appeared in the doorway of a Starbucks and "attempted to assassinate" the two officers on Sunday, Vallejo Police Chief Andrew Bidou said.
The officers were not injured because the battered weapon, its butt covered with duct tape or foil, appeared to jam. Powell of Suisan City was in critical condition after being shot by the officers during a foot chase.
It was the latest attack on police across the country. Earlier this month, a man in body armor shot and killed two officers in Palm Springs who were responding to a domestic disturbance call at the home of an ex-convict's family.
That shooting occurred just three days after Los Angeles County sheriff's Sgt. Steven Owen was shot and killed in Lancaster while answering a burglary call. Owen was the victim of "a calculated execution" by a parolee with a long history of arrests who pumped bullets into his body as he lay wounded, Sheriff Jim McDonnell said.
Bidou said he attacks have led to a heightened sense of alert among police.
He gave no further information on a motive for the attack in Vallejo, where the gunman kept trying to fire the assault-style weapon as he fled from the officers, police said, noting that the man was also carrying a loaded handgun.
The officers "were ambushed by somebody who has superior firepower," Bidou said.
Police say Powell fled when he could not get the weapon to fire.
Officers said they caught up with Powell about 100 feet from the Starbucks and he was shot three times in a neighborhood of small houses next to a freeway on-ramp.
Jazmin Addison, who lives next to the intersection, said she heard more than a dozen shots. "It was scary. I made my kids get down on the floor," she said.
She later saw the suspect on the ground, with numerous police around him.
Authorities said Powell had served prison time for robbery and drug-related offenses and was barred from possessing guns.
Bidou said Powell is the father of a 2-year-old boy who may have accidentally shot himself earlier Sunday in Suisun City, about 50 miles north of San Francisco. The child was taken to a hospital for a gunshot wound.
Police said preliminary information indicates the wound was accidental and self-inflicted. Powell was present when the child was shot and left the home before officers arrived, police said.
In Palm Springs, prosecutors say a gang member killed two police officers and wounded a third.
John Hernandez Felix, who has pleaded not guilty to murder charges, wore body armor and used armor-piercing ammunition when he opened fire with an AR-15 rifle on officers who came to the door, prosecutors said.
Five Dallas police officers were killed in a sniper attack this summer and earlier this month, a gunman also wearing body armor was fatally shot after critically wounding two police officers in Boston.
Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.