Mark Anthony Estrada, 21, is accused of gunning down Sgt. Scott Lunger, a 15-year veteran of the Bay Area department.
Estrada is hospitalized undergoing treated for gunshot wounds, but remains in custody, Hayward Police Chief Diane Urban told reporters.
Asked to describe the suspect's possible motive, Urban didn't mince words.
"There's no why," she said. "It's an absolutely senseless murder."
Shot 'without warning'
Lunger pulled over a vehicle he saw driving erratically shortly after 3 a.m.
"As Sgt. Lunger got out of the car and approached the driver side of the vehicle, the driver shot Sgt. Lunger without warning," Capt. Mark Koller told reporters.
Another officer was on scene and returned fire, Koller said. The driver fled. The vehicle was later abandoned in Oakland, where it was recovered.
Chief: Slain officer was a 'warrior'
Urban described Lunger as a friend and warrior.
"He was a great leader here in our organization. He inspired people every day -- an incredible friend, a great father, a brother, a husband, a partner," she said. "We have really suffered a tremendous loss today, and the world is a little bit worse for him being gone."
Koller described Lunger as a close friend, well-respected, accomplished and an "ideal police officer."
"This is a very devastating and dark day for the community of Hayward," Koller said.
Police: Suspect had gang ties
The police chief didn't specify what charges Estrada would face.
It wasn't immediately clear whether he had legal representation.
Urban said Estrada was not cooperating with investigators and "is associated with a gang," but she added that he was "not a validated gang member."
He has no known previous criminal record, she said.