The two officers were on a gang-suppression patrol in southeast San Diego on Thursday night when one put out a call for help.
Moments later, officers arrived to find one colleague fatally shot and the other critically wounded.
A trail of blood led police to a suspect who had been shot in the chest. Police detained another man Friday during a search for a second possible suspect.
In San Diego, it was the third fatal shooting of a police officer since 2010, but the first during the 28-month tenure of police Chief Shelley Zimmerman.
"Tragically, one of our officers was murdered last night," Zimmerman told reporters late Friday morning.
The chief said she personally visited the wife of slain officer Jonathan DeGuzman, 43, a 16-year veteran and father of two, to inform her of the tragic encounter. She had also gone to the hospital to check on Officer Wade Irwin, 32, who was expected to survive.
"It is extremely difficult but something you have to do," Zimmerman said. "There's nothing that prepares you to do that."
DeGuzman became the 10th police officer fatally shot in the line of duty in the U.S. this month, causing Zimmerman to lament the increase in violence against law enforcement.
"That's just a tragic statistic of police officers that go out every single day that wear a badge with pride that we all took an oath to protect and serve all of our communities," she said. "And to have this happen to our police officers -- we have seen this happen way too many times just in these last few weeks across our great country. It is tragic for everyone."
It was unclear Friday exactly what prompted the shooting. Police said the incident, at least in part, had been captured on one officer's body camera. They did not disclose what was recorded.
DeGuzman and Irwin were patrolling in uniform and in a marked car as part of the city's 10-team Street Gang Unit. According to the department's website, the teams work seven days a week citywide patrolling areas where gang crime is prevalent. They focus on felony gang crimes.
Police arrested Jesse Michael Gomez, 52, shortly after the incident about 11:30 p.m. Thursday in the Chollas Creek ravine just south of the site of the shooting, Zimmerman said. Officers followed a trail of blood to him. He was critically injured by a gunshot wound to his upper chest.
Police, including officers from many other agencies, swarmed the area searching for another suspect with the aid of police dogs, helicopters and heavily armed SWAT team members. They focused for hours on the ravine just south of Acacia Grove Way.
Shortly before sunrise Friday, no other suspects had been found and many officers from the other police agencies were released from their posts by 4 a.m. and some streets reopened after that.
Then later Friday morning, officers surrounded a house on Epsilon Street near 41st Street in Shelltown, about a half-mile from the initial shooting at Acacia Grove Way near 37th Street.
They remained there for hours, trying to persuade the man, who they believed to be inside, to surrender. Other family members were reported to have gotten out of the residence before the standoff.
A negotiator using a bullhorn repeatedly appealed to "Marcus" to come out.
"We're not going anywhere," the officer called out. "It has been a really long night. I'm worried about you. I haven't heard from you for a while.
"I need to hear from you. You need to talk to me. Your sister ... is really scared. What should I tell her? It's not fair to have your sister so worried about you."
Officers fired about 50 gas bombs into the home, which had an armored SWAT vehicle in the driveway. A remotely controlled robot searched the house and no one was seen through its camera, but it couldn't open a closet.
A few moments later, the officer could be heard on the bullhorn saying, "Hey, Marcus. We hear you coughing in there. Come on out." But hours later, SWAT officers entered the home and apparently found no one there.
Officers later arrested Marcus Antonio Cassani, 41, about three blocks away, standing in the middle of the street waiting for them to arrest him. His sister had called police to tell them where to find him. Investigators have not determined whether he was involved in the shooting, but he had a warrant out for his arrest from Anaheim.
San Diego Mayor Kevin Faulconer expressed sadness over the shooting of the officers and asked the community to support law enforcement.
"Violence against the men and women who wear the badge is violence against us all," he said in a statement. "We need them and they need us."
Times staff reporter Doug Smith and San Diego Union-Tribune staff reporter Pauline Repard contributed to this report.
Hernandez and Winkley write for the Union-Tribune.
5:30 p.m.: This article was updated with the names of two men who have been arrested.
4:45 p.m.: This article was updated throughout with additional material.
3:25 p.m.: This article was updated throughout.
2:10 p.m.: This article was updated with details on the SWAT standoff.
11:30 a.m.: This article was updated with comments from Zimmerman.
9:35 a.m.: This article was updated with details of police surrounding a house and speaking to a possible suspect.
9:15 a.m.: This article was updated with comments from San Diego's mayor and Donald Trump.
8:35 a.m.: This article was updated with details throughout.
7:10 a.m.: This article was updated with details on the suspect search.
4:55 a.m.: This article was updated with details throughout.
3:40 a.m.: This article was updated with the death of one officer.
July 29, 12:55 a.m.: This article was updated with one suspect in custody.