A police officer in California's Central Valley was shot and killed Tuesday and a suspect was arrested.

The Selma officer was patrolling in the small Fresno County city shortly before noon when someone flagged down his patrol car and said there was a suspicious person in a yard, KFSN-TV reported.

As the officer left his car, he was shot several times. He was later pronounced dead at a hospital. His name wasn't immediately released.

TEXAS MATH TEACHER SENTENCED TO 20 YEARS FOR DISTRIBUTING CHILD SEXUAL ABUSE MATERIAL

CA crime

A 23-year-old suspect is accused of fatally shooting a cop several times after the officer left his car in California. (Fox News)

A 23-year-old man was later found and arrested and a gun believed to have been used in the shooting was seized in the area, police said.

"I’m absolutely outraged. I am horrified right now," Selma Police Chief Rudy Alcaraz during a press conference.

CLICK HERE TO GET THE FOX NEWS APP

The motive for the shooting was under investigation but may have been gang-related, Fresno County Sheriff John Zanoni said.

The man arrested had a criminal record that included robbery and gun possession charges and he was wanted by probation officers, authorities said.