LOS ANGELES (AP) — A gang member who was recently freed from jail killed his cousin and stole his car Monday then shot and killed a California police officer and wounded his partner before being wounded himself, authorities said.

Whittier Officer Keith Lane Boyer died and Officer Patrick Hazell was wounded when they answered a report of a traffic accident in the eastern Los Angeles County suburb.

A motorist pointed out the location of the car that had rear-ended his vehicle, and the officers approached the driver.

“When they get him out of the car, they go to pat him down for weapons, they can see he’s got tattoos all over his face and all over his neck,” county sheriff’s Lt. John Corina said.

The man then pulled a semi-automatic handgun from his waistband and opened fire at the officers, who were wearing bulletproof vests and shot back, Corina said.

“They walked up on the vehicle believing the motorist was in need of medical help and then they ended up in a gunfight for their lives,” Sheriff Jim McDonnell said.

Whittier Police Chief Jeff Piper wept as he described Boyer as a friend of more than 25 years.

“All of us have been grieving,” the chief said. “And I didn’t think I had any tears left.”

Gov. Jerry Brown issued a statement of condolence. Capitol flags were ordered to be flown at half-staff in his honor.

Monday night, hundreds of people held a candlelight vigil for Boyer at police headquarters. Piper told them that he planned to write a song for Boyer, who played with him in an off-duty band.

The suspect, a 26-year-old gang member, had a history of serious crimes and had been granted early release from Los Angeles County jail about a week ago, Corina said. He didn’t know the nature of his offense.

His name wasn’t immediately released.

Earlier Monday, he shot and killed his cousin in East Los Angeles and took his car, which later rear-ended another car in the neighboring city of Whittier, Corina said.

He got out and asked those he had hit to help push his stolen car from the intersection.

Boyer and Hazell didn’t know any of those details when they answered the report of a car accident, Corina said.

Boyer was pronounced dead at a hospital. Hazell, a three-year veteran, and the suspect were hospitalized in stable condition and were expected to live.

After the shooting, a long line of police cars escorted the slain officer’s body from a hospital in Irvine to the coroner’s office. Mourners placed candles and flowers outside police headquarters.

Boyer joined the force as a dispatcher in 1989 and became a full-time officer in 1990. A divorced father who played the drums, he was “the best of the best” who was sought for advice by his colleagues and superiors, the chief said.

Boyer recently talked to the chief about retiring.

The Whittier Police Department has about 125 sworn officers who patrol Whittier and Santa Fe Springs.

The department has had two other officers killed in the line of duty — a detective in 1979 and a corporal in 1977.