Four police officers were fatally shot and another was wounded in the northern Californian city of Oakland on Saturday. The suspect was later killed by police.
Officials said the perpetrator first opened fire on two motorcycle police officers during a routine traffic stop, killing one and critically wounding the other, who died in hospital on Sunday.
Police launched a manhunt for the man, who shot and killed two more officers before police fatally wounded him.
A wounded officer was treated and released from hospital late Saturday.
California Governor Arnold Schwarzenegger called the officers deaths tragic, and ordered state flags be flown at half-staff.
News reports said that Schwarzenegger, who was in Washington over the weekend, was on route to Oakland Sunday.
This is a tragic day for law enforcement officers everywhere, he said, adding the slain police had dedicated their lives to public safety and selflessly worked to protect the people of Oakland.
The dead suspect, who was out of prison on parole and who had a long criminal record, was identified by police as Lovelle Mixon, 26.
Authorities said the Oakland officers killed were Mark Dunakin, 40; Ervin Romans, 43; Dan Saki, 35, and John Hege, 41.
Officials said it was the first time an officer in the city was killed in the line of duty in five years.
The shootings triggered a citywide manhunt involving dozens of Oakland police, California Highway Patrol officers and sheriffs deputies for Alameda County.
Eventually, Mixon was tracked down in an apartment building where he was shot and killed by police.
One witness, who did not want to be identified, said he heard gunshots from outside, where he saw two officers laying on the ground.
I went over to one officer and saw he was bleeding from his helmet pretty bad, he said. The other officer was laying motionless.