Three suspects were in custody after they shot a police officer in plainclothes in a botched robbery outside the Downey Police Department overnight, authorities said.

Officials believe the alleged assailants didn't know the victim, 29-year-old Ricardo “Ricky” Galvez, was a cop.

He “was sitting in his personal vehicle in the Downey Police Department parking lot when a vehicle drove into the parking lot and unknown suspects exited the vehicle, ran up to Galvez’s car and fired shots into his vehicle, fatally striking him,” Los Angeles Sheriff's Department Deputy Guillermina Saldaña said.

Galvez was pronounced dead at the scene. It happened about 11 p.m. at the Downey Civic Center at 10900 Brookshire Ave. in Downey, authorities said. The department apparently shares a public parking lot with a library and other city offices.

Sheriff's Lt. John Corina told reporters that investigators believe the lawman, sitting in his parked car, was targeted, but not because suspects believed he had a badge.

“They were out looking to rob somebody,” he said.

Suspects fled the Downey city parking lot in a vehicle, and an on-duty Downey cop in a patrol car gave chase when gunshots were heard.

The pursuit led to Carob Way and Washington Boulevard in Montebello, where the suspects fled on foot, sheriff's officials said. One of them was nabbed on the spot, deputies said.

Two others were arrested during a follow-up investigation that included a SWAT team and search-warrant raids, authorities said. The suspects included two men and a 17-year-old boy, sheriff's officials said. Identities were not released.

Galvez, a five-year veteran of the department, was a former U.S. Marine, police said. He's survived by his mother, brother, multiple sisters and “numerous friends and colleagues,” the Downey department said in a statement.

“Every day, the brave men and women of our Downey Police Department put themselves at personal risk to keep us all safe,” Downey Mayor Luis H. Marquez said. “We are incredibly sorrowed at the loss of Officer Galvez, and our thoughts and prayers are with all who knew and loved him.”

With reporting from City News Service

LA Weekly