On July 8, five Dallas police officers were gunned down by a sniper. Ten days later in a neighboring state, three Baton Rouge police officers were shot and killed.

The deaths shocked the nation and threw into sharp relief divisions between police departments and protesters calling for reform. The assailants stated that they wanted to kill police officers, officials said after the attacks.

In less than two weeks' time that July, more police officers had been killed in targeted ambush attacks than all of last year, according to FBI data.

On Wednesday, Riverside County District Attorney Mike Hestrin spoke the same chilling words as the officials in Dallas and Baton Rouge: “This individual wanted to kill police officers.”

The community of Palm Springs attends a vigil for fallen officers Jose Gilbert “Gil” Vega and Lesley Zerebny on Sunday, Oct. 9, 2016 in Palm Springs. The two officers were killed in the line of duty the day before.(Photo: Richard Lui/The Desert Sun)

During a press conference that day, Hestrin announced two counts of first-degree murder and three counts of attempted murder against John Hernandez Felix, the suspect in Saturday’s shooting that left two Palm Springs police officers dead. Hestrin characterized the attack as an ambush.

“I think that these officers walked into a trap. He set out to kill them,” Hestrin said.

Jose “Gil” Vega, a 35-year veteran on the force, and Lesley Zerebny, a rookie and new mom, were killed responding to a routine domestic disturbance call. Vega was the first officer to walk up to the front door to speak to Felix, who allegedly shot the officers with an AR-15 through a metal screen door. When he was captured 12 hours later, Felix was wearing a bulletproof vest and had high-capacity magazines on his body, police later said.

Vega and Zerebny were the first Palm Springs police officers to be killed in the line of duty in 54 years.

In 2016, the number of ambush killings of police officers is significantly up compared to the previous five years, according to FBI statistics. This year, preliminary numbers show 18 officers have been killed in premeditated or unprovoked attacks compared to seven in 2015.

While the number of overall police deaths has declined in the past 20 years, the number of ambush-style killings has not, though it continues to fluctuate from year to year.

Officers across the country acknowledge that ambush killings are not a new phenomenon, but they say that the level of animosity between police and the communities they patrol is at an all-time high. From the perspective of an officer, each ambush is a reminder that the people they serve and protect can kill them.

“What worries me in recent days, recent months and years really … is an anti-cop sentiment here in this country,” said Craig Floyd, president and CEO of the National Law Enforcement Officers Memorial Fund. “It’s been spewed by a vocal few but been amplified by the media and by politicians.”

In communities across the country, several high-profile killings of young, black men have prompted calls for increased scrutiny of police use of force. Media coverage of such events, driven by smartphone video and social media along with the 24-hour news cycle, has led to heightened awareness, protests, social movements and what officers perceive as retaliation against law enforcement.

For police departments engaged in community policing, like Palm Springs, these ambush killings can have lasting repercussions, said Sheriff Michael Bouchard of Oakland County, Mich.

“It is a challenging time because (the Palm Springs shooting) comes at a time when as a profession we are doing more to engage the community to build trust,” Bouchard said. “Cops need to be helpful and friendly and approachable while suspecting anyone could be trying to kill them.”

Each time an officer is ambushed on the job, that balance between community defender and potential victim is thrown off because surviving officers are in a heightened state of alert, he added. Bouchard is a member of the Major County Sheriffs' Association, which is comprised of elected sheriffs from large counties.

Although increased awareness of police killings creates the perception that being an officer is more dangerous, the facts don’t back that up. Ambushes this year are up, but overall police deaths on the job have been decreasing over the past two decades, according to FBI data.

“If you look at the numbers you’ll see that it’s safer today than it ever has been,” said Jim Bueermann, former Redlands police chief. “That doesn’t mean that police officers believe that. When you have multiple officers killed in an ambush setting, this shocks the collective conscience of American policing in ways that are hard to describe.”

The number of officers killed in an ambush makes up about 8 percent of total police deaths. But officers are subject to the same emotions as anyone else, said Bueermann, who is also the president of the Police Foundation, a national nonprofit focused on research and police policy issues. Most officer deaths, about 55 percent, are attributed to accidents.

The litany of police ambush killings in 2016 have caused officers to believe that targeted attacks are the norm even if it may not be, Bueermann added.

Ricardo Hinojosa cries at his uncle Jose Gilbert &ldquo;Gil&rdquo; Vega's vigil on Sunday, October 9, 2016 in Palm Springs. Vega and officer Lesley Zerebny both died in the line of duty the day before.

(Photo: Richard Lui/The Desert Sun)

“The numbers may stay the same, but it doesn’t feel that way,” said Sgt. Timothy Gauerke of the Milwaukee Police Department.

In July, an officer on Gauerke’s force responded to a domestic disturbance call. When the officer arrived, nobody was home. The officer returned to his patrol car. As he was sitting in the driver’s seat, the suspect came back and shot the officer in the torso multiple times before killing himself.

Although the officer survived, Gauerke said the shooting put his department on edge. “It kind of sinks in that it could be a reality when one of our own is injured,” he added.

Gauerke isn’t the only law enforcement official to express this sentiment.

Two years ago, in Brentwood, N.H., a police officer was killed in a situation that mirrored the Palm Springs shooting.

The officer, a 17-year veteran, responded to a domestic disturbance call involving a father and son. He entered the house and was shot and killed by armor-piercing bullets. The shooter used a semi-automatic rifle.

“There is never any going back to normal,” said Sgt. H.D. Wood of the Brentwood Police Department. “Quite frankly I don’t think you ever want to return to normalcy because there is a feeling that you are forgetting your officer who passed on.”

In 2016, about 77 percent of Americans have “a lot” or “some” confidence in their local police, according to a survey done by the Pew Research Center in September. A separate Pew survey shows that number has remained relatively constant since 2009. However, when broken down by race, disparities emerge. About 55 percent of African Americans said they had “a lot” or “some” confidence compared to 81 percent of their white counterparts.

The survey indicates two leading motives spurring protests against police use of force: the desire to hold officers accountable for their actions and a long-standing bias against police. African Americans were more likely to cite accountability as the reason for protests, according to the survey.

Scrutiny of police actions is justified, Bueermann said, but technology and the changing role of police officers in society have complicated the relationships police try to build with their community. Officers are now expected to be the first responders to mental illness, homelessness, substance abuse, addiction and other “social ills” that in the past didn’t fall under police purview.

“The police are the only public group of people charged with enforcing the law that allows them to use force, subsequently deadly force without prior judicial review," he explained. "That then makes policing a very unique thing in our society and therefore going to be subject to a lot of scrutiny and perhaps displeasure when things don’t go as well as everybody hoped they would on certain types of calls."

Domestic disturbance calls, like the one Vega and Zerebny responded to, can be the most unpredictable and dangerous incidents for officers to approach. He added that their deaths will likely be felt for a long time.

“In smaller police departments like the one I came from or Palm Springs, they tend to be very family-like, so it devastates the department,” Bueermann said. “When more than one officer is killed, the magnitude of the pain and suffering on the part of the officers is ramped up exponentially, and when they are ambushed it’s even more.”

In Palm Springs, the halls of the police department are crowded with wreaths sent by officers from across the country. The smell of cut flowers lingers in the air. A memorial dedicated to fallen officers has been heaped with bouquets, candles, balloons and messages for Vega and Zerebny. The statue atop the memorial can hardly be seen under the pile of tributes.

Though the tokens seem small, they mean a lot to officers, said Brentwood Police Sgt. Wood. After the Brentwood shooting, the police relied on the community to bolster their emotions. Palm Springs should do the same, he said.

“I would say to members of the community just to thank a Palm Springs police officer for their service,” Wood said. “Little do they know those simple words of encouragement go a long way to a grieving officer.”

During a vigil attended by hundreds of community members and city leaders, Palm Springs Police Chief Bryan Reyes offered his own simple advice.

"When this is all over, don't just turn around and walk away. Take the time to introduce yourself to each other, because this is the community we live in," Reyes told the crowd gathered Sunday. "We will all get through this together.”

Desert Sun reporter Gustavo Solis can be reached at 760-778-6443 or by email at gustavo.solis@desertsun.com. You can follow him on Twitter @journogoose. Desert Sun reporter Kristen Hwang can be reached 760-668-2910 or by email at kristen.hwang@desertsun.com. You can follow her on Twitter @khwangreports.

The community of Palm Springs attend the vigil for fallen officers Jose Gilbert “Gil” Vega and Lesley Zerebny on Sunday, October 9, 2016 in Palm Springs. The two officers were killed in the line of duty the day before.