Downey, Calif., city firefighters furl a large American flag that had flown atop a ladder truck over a procession of vehicles carrying the body of Downey Police Officer Ricardo Galvez in Downey Thursday, Nov. 19, 2015. Galvez was in plainclothes in his personal car in the police department headquarters parking lot when two men ran up and opened fire late Wednesday. (AP Photo/Nick Ut)

DOWNEY, Calif. (AP) — Three young men were arrested Thursday on suspicion of killing a California police officer and former Marine in what investigators described as a botched robbery as the lawman sat in his own car after work.

Downey police Officer Ricardo “Ricky” Galvez, 29, was in plainclothes in the driver’s seat of his car at the end of his shift when two men ran up and opened fire late Wednesday, Los Angeles County sheriff’s Lt. John Corina said. The five-year department veteran died in the car.

Corina said two men in their 20s and a juvenile were out looking for someone to rob when they spotted Galvez sitting in his car after he just finished work. Galvez was shot seconds later.

“They were attempting to rob Officer Galvez not realizing he was a police officer,” Corina said. “I don’t even think he saw these guys coming up on him.”

Another officer heard the gunshots and pursued the attackers as they fled into the neighboring city of Montebello. Investigators said they arrested the getaway driver shortly after and detained a number of other people after SWAT officers swept surrounding neighborhoods.

The other two arrests were announced later. The names of the suspects were not released.

Corina said detectives knew quickly that Galvez was shot in a targeted, deliberate attack.

“It appeared to be an ambush style. It happened very quickly,” Corina said after viewing surveillance video of the shooting.

Corina said he wasn’t immediately able to tell if words were exchanged before Galvez was shot.

Downey police Chief Carl Charles praised Galvez’s professionalism and said the officer had an infectious smile and a great attitude.

“Words cannot express the love we have for Ricky,” he said.

Galvez was a Marine veteran from the Downey area. He was single and lived close to his siblings and other family members, Charles said at a news conference.

Downey police Lt. Mark McDaniel said Galvez “loved serving the city and he loved serving his country.”

“If you could mold a police officer, you would mold that police officer after Ricky Galvez,” McDaniel said. “We have a lot of police officers here who are hurting. We’ll never get over it and we’ll always remember Ricky.”

Dozens of officers wiped away tears and saluted as police carried Galvez’s American flag-draped body from the crime scene to a coroner’s van.

Downey is a city of about 110,000 residents 10 miles southeast of downtown Los Angeles.

Copyright 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.