On Friday, Darren Goforth, a sheriff’s deputy in Texas, was filling up his car with gas when another man approached him and opened fire. Goforth, a married father of two children, died after being shot multiple times by a gunman who continued firing after the deputy had fallen to the ground, authorities said. The following day, police announced that they had arrested Shannon J. Miles, 30, and charged him with capital murder.

Authorities have not publicly identified a motive in the shooting yet, other than to say they believe Goforth “was a target because he wore a uniform,” as Ron Hickman, the sheriff of Harris County, said at a news conference Saturday. Even before Miles’s name and arrest were announced, Hickman and Devon Anderson, the county’s district attorney, linked the shooting to the protest movement focused on how police use lethal force.

“This rhetoric has gotten out of control,” Hickman said. “We’ve heard ‘black lives matter,’ ‘all lives matter.’ Well, cops’ lives matter, too. So why don’t we just drop the qualifier and just say ‘lives matter’ and take that to the bank?”

Hickman later clarified that authorities were still investigating to see if the protests played any role in Goforth’s death. “The general climate of the kind of rhetoric can be influential on people that do things like this,” he said at a news briefing. “We are still searching to find out if that’s actually a motive.”

In quickly tying this shooting to the protests, these officials tapped into a larger sentiment that exists among law enforcement in the United States: A sense of increased tension amid the demonstrations criticizing police in cities like Ferguson, Mo., Baltimore, Cleveland and across the country.

“I do believe there are more people today that have an anti-public safety mindset,” Baltimore County Police Chief Jim Johnson, who is also chairman of the National Law Enforcement Partnership to Prevent Gun Violence, said in an interview earlier this summer.

Overall, statistics show that policing is becoming safer, as the number of officers shot and killed is believed to have declined for each of the last four decades. But Johnson said a recent increase in the number of officers killed in ambushes is particularly alarming, and he believes the number of officers killed would “be much higher” if not for advances in medical and trauma care as well as improvements in protective gear.

Still, concerns about increased danger were echoed by numerous current and former law enforcement officers, as well as their family members, who said in interviews this year that they feel under attack in the current atmosphere. Some officers said they have become extra cautious, while others described being taken aback by the level of anger and duration of the protests.

“We don’t do this job for the money, for awards, for notoriety,” said Anthony Scaglione, 47, who retired last year after 21 years with the Ithaca, N.Y., Police Department. “We do this job because we care. It takes a very special person to do this job, especially these days.”

Officers say being a police officer can be complicated by the ubiquity of cellphones, which allow any interactions to be recorded. Some officers have been followed by people or groups with cellphones while on routine calls, which can be challenging for the officers, Johnson said.

“If you imagine someone with a cellphone recording every moment … it’s tough,” said Don Costa, 58, who spent two decades as a detective in Waterbury, Conn. “Are you going to make that one slip? It’s very difficult.”

These concerns come amid a backdrop of protests against police that has been prominent over the last year, but they also occur as statistics suggest that policing has become safer. Goforth was the 23rd police officer shot and killed by a suspect this year, according to the Officer Down Memorial Page, a nonprofit organization that tracks line-of-duty fatalities. Three days earlier, Henry Nelson, a Louisiana police officer, was shot and killed after responding to a report of a domestic dispute.

Fewer police officers were shot and killed by suspects so far this year than through the same point last year. More police officers have died in the line of duty so far this year than by the same point last year, though that is due largely to an increase in traffic accidents.

Records from the National Law Enforcement Officers Memorial Fund, a nonprofit in Washington that studies officer fatalities, show that about 50 police officers have been shot and killed each year over the last decade, a number that is significantly down from the 1970s, when an average of 127 officers were shot and killed per year. This figure has declined during each of the decades that followed.

Goforth’s death has drawn comparisons to the killings of two New York City police officers — Wenjian Liu and Rafael Ramos — who were shot and killed while sitting in their patrol car last December. Police said the man who gunned them down had made threats against police on social media, and officials in New York and elsewhere placed some of the blame on the protests.

“Let’s face it, there’s been, not just in New York but throughout the country, a very strong anti-police, anti-criminal-justice-system, ant-societal set of initiatives underway,” William J. Bratton, the New York police commissioner, said after Liu and Ramos were killed. “And one of the unfortunate aspects sometimes is some people get caught up in these and go in directions they should not.”

Activists called the New York shooting a tragedy and said it was unrelated to the protests. Since Goforth’s death, though, the statements from Texas officials have been echoed by questions from pundits and high-profile voices elsewhere in the country who have linked the shooting to the Black Lives Matter protests.

“Why has the Black Lives Matter movement not been classified yet as a hate group?” Elizabeth Hasselbeck, co-host of the Fox News show “Fox & Friends,” asked a guest on Monday. “How much more has to go in this direction before someone actually labels it as such?”

Milwaukee County Sheriff David A. Clarke Jr., a frequent critic of the Black Lives Matter protests, said over the weekend on Fox News that people protesting against law enforcement are “slime” and “filth.”

Clarke reiterated his stance that President Obama “started this war on police,” echoing remarks he made after two police officers in Mississippi were fatally shot in May.

“Any time a law enforcement officer is killed, a little of every police officer in America dies along with them,” Clarke said. He added: “This was an assault on the American way of life, the American justice system.”

People involved in the protest movement argued against the suggestion that the demonstrations around the country played a role in Goforth’s death. “The movement has never condoned any violence against police officers,” Kayla Reed, an organizer in St. Louis, told the New York Times.

DeRay Mckesson, one of the most high-profile activists in the Black Lives Matter movement, criticized what he called a decision “to politicize this tragedy.”

The killing in Harris County, which is home to Houston, affected a sheriff’s office that is among the largest local law enforcement agencies in the country.

“Texas has sustained a deliberate and heinous crime against a law enforcement officer in Harris County,” Gov. Greg Abbott (R) wrote in a letter ordering flags in the state to be flown at half-staff in Goforth’s honor. “Texans revere the men and women in law enforcement who put their lives on the line every day to protect and serve their communities.”

Killings of police officers are viewed differently by the country’s legal system than many other crimes because of what law enforcement represents, experts say. In federal cases and many states, including Texas, killing a law enforcement officer is an aggravating factor that can warrant the death penalty.

“The entire justice system is, in a way, the victim when a police officer is killed,” said David A. Harris, a law professor at the University of Pittsburgh. “So a person who kills a police officer in the course of that police officer doing his or her duty seen, in many ways, as committing an assault against all of the forces of law and order.”

While many pundits and other observers have linked Goforth’s death to the officers gunned down in New York last December, these incidents both evoked another law enforcement death that occurred last year. Igor Soldo and Alyn Beck, two Las Vegas police officers, were wearing their uniforms and eating lunch when a married couple came in and opened fire, killing the two officers.

This shooting was attributed at the time to the couple’s anti-government beliefs, which authorities described as viewing law enforcement as the enemy. But after that incident — and this was well before protests against how police use lethal force became an ongoing national conversation — several experts said they were concerned about an increasing danger to police officers, who walk around in uniforms that make them readily visible.

Ambush attacks, in particular, were a cause for concern, Johnson said. Last year, 15 officers were shot and killed in ambush attacks, which matched 2012 for the highest number over the past decade, according to National Law Enforcement Officers Memorial Fund. These deaths reverberate nationally, because “even if the incident occurred in Mississippi or New Orleans, officers here see that as a threat to their safety and well-being,” Johnson said.

“All we have is each other,” said Scaglione, the retired officer from Ithaca. “We’re the only ones that know what it’s like.”