Cirilo Martinez was in Dallas on vacation when he heard shots fired from across the street from his hotel. He describes seeing police officers shot by a gunman. (Whitney Shefte,Dalton Bennett/TWP)

The sniper-style ambush killings of five police officers Thursday evening in Dallas is the deadliest mass shooting of law enforcement in 84 years.

The massacre brought the number of on-duty officers who have been shot and killed this year to 25 — up from 16 at this point last year. More than one-third of the slain officers this year, a total of 10, have died in ambush attacks, concealed or unexpected assaults designed to catch law enforcement off guard.

The killings in Dallas have a particular resonance within the Harford County Sheriff’s Office in Maryland. It has been five months since two deputies there were unexpectedly shot and killed after they responded to a call about a dangerous man seen at a Panera Bread in an Abingdon shopping mall.

“To hear that this many officers have lost their lives and others are still fighting for their life, it’s a horrible thing,” Harford County Sheriff Jeffrey R. Gahler said. “It’s a new normal, and I think we figure out minute by minute how to adjust to it.”

Since 2005, according to FBI data, about 20 percent of fatal shootings of police have been ambushes. Fatal shootings of police are up over last year, but the FBI data shows that the rate this year is in line with previous years over the past decade, which have averaged 53 killings a year.

The victims of the Dallas protest shooting

The slain officers identified in Thursday’s killings are Dallas Police Officers Patrick Zamarripa, Michael Krol, Michael Smith and Lorne Ahrens, and Dallas Area Rapid Transit Officer Brent Thompson. Seven other officers were wounded.

“These officers were killed because of the uniform they wear, because of the job they do,” said Craig W. Floyd, president and chief executive of the National Law Enforcement Officers Memorial Fund. “They are the most visible and vulnerable symbol of government and authority. And they are being targeted by weak-minded individuals who are easily influenced by a lot of anti-cop, anti-government rhetoric we have been hearing.”

The gunman, Micah Johnson, 25, of Mesquite, Tex., was killed by police with a bomb robot. Before he died, Johnson told police he had acted alone and wanted to kill “white people,” especially police, in the wake of two recent shootings by police of black men in Minnesota and Louisiana.

Among the other officers who were fatally shot this year:

Thomas Cottrell, 34, an officer in Danville, Ohio, was shot and killed Jan. 17 in an ambush attack behind the police station where he worked. Police dispatchers received a tip from a female caller telling them that Danville officers “were in danger” because her ex-boyfriend had “left with weapons and was looking to kill an officer.” Cottrell’s body was found 27 minutes after that 911 call.

Ashley Guindon, 28, a Prince William County, Va., police officer, died Feb. 27 while responding to a domestic disturbance call. The gunman, an Army sergeant, first shot and killed his wife and then shot Guindon. She had been sworn in the previous day and was working her first shift as an officer.

The last mass shooting of police took place on Nov. 29, 2009, when four officers in Lakewood, Wash., died after a gunman entered a coffee shop and opened fire on them as they worked on their laptop computers, preparing for their shifts. That same year, on March 21, four police officers in Oakland, Calif., were shot and killed by a gunman.

The Dallas shooting is the worst single mass shooting of police since Jan. 2, 1932, when six Missouri law enforcement officers died in a shootout after they attempted to apprehend two murder suspects in what became known as the Young Brothers Massacre.

Family members of officers killed in earlier shootings said Thursday’s incident — and the renewed protests and outrage this week over police use of force — have reopened old wounds.

“The pain returns,” said Tim McNeil, uncle of Kerrie Orozco, an Omaha police officer who was shot and killed by a gang member last year as she was attempting to serve him with a felony arrest warrant.

“Officers say goodbye to their families and go to work, trying to keep the public safe, and right now they are doing it in an environment where there is so much hatred, revenge and vindictiveness,” said McNeil, who has become a police chaplain since his niece’s death. “They are all looking over their shoulders.”

Floyd said that most officers who die in the line of duty are killed in traffic accidents, not shootings. Over the past decade, an average of 53 on-duty officers have died in fatal shootings out of the overall yearly death toll of 144.

A 2010 Washington Post study of fatal shootings of police showed officers more commonly died during traffic stops or when responding to domestic disturbances than they did in ambush-style shootings. From 2000 to 2010, a total of 511 officers were fatally shot, with 91 dying during traffic stops, 76 while responding to domestic disturbances and 43 dying in an ambushes, the study showed.

Floyd said the men who have shot and killed officers this year generally fall into two categories — the mentally ill and career criminals. “Many should be institutionalized,” he said. “Others are cold-blooded criminals who simply hate cops because they know that they are what stands between them and the havoc and chaos they want to wreak on the rest of us.”

Floyd also said some of the attackers this year have claimed to have ties to terrorist groups after the shootings. He points to one involving Philadelphia Police Officer Jesse Hartnett, who survived a Jan. 7 ambush attack in which a gunman fired 13 shots at him as he sat in his patrol car. The gunman later told police he had pledged his allegiance to the Islamic State.

In recent years, while the number of police shot and killed in the line of duty has declined, officers themselves have described increased tension as they do their jobs, arising from heightened community suspicion and increased official scrutiny on their use deadly force.

Current and former police officers say they feel under siege and vulnerable. Officers have said they keep their guns with them at times when they usually wouldn’t and feel the taunts of those who follow and film them with cellphones during calls for service.

This phenomenon has been called the “YouTube effect” by New York City Police Commissioner William J. Bratton and the “viral video effect” by FBI Director James B. Comey.

During remarks earlier this year, Comey said he was concerned that a jump in homicides in dozens of major cities across the country may have been related to police officers becoming less assertive in response to the protests and viral videos. Comey said that he had heard from police leaders across the country about “a change in the way police are doing their work . . . and in the way communities are interacting with police.”

Floyd said that although the nation is mourning police officers who were slain while on duty, he hopes the concern for law enforcement is not temporary.

“At times like these, people want to support law enforcement,” he said. “But surviving family members of officers who have died say, ‘So many people said so many nice things after they died. I wish those nice things had been said when they were still alive.’ ”

On Wednesday, the Harford County Sheriff’s Department and state officials dedicated a stretch of the road near the mall, naming it in honor of their two slain deputies, Patrick Dailey, 52, and Mark Logsdon, 43, who were killed by a lone gunman in February.

Since its founding in 1774, the department has lost only five officers in the line of duty.

For now, Gahler has not mandated that patrol cars be staffed with two deputies, a move made by several other departments following the Dallas shootings. But Gahler knows that his deputies are at renewed risk, and he told them to stay alert as they patrol the county just north of Baltimore. He also asked them to wear black shrouds on their badges to honor the slain Dallas officers.

“Please stay vigilant and alert as you keep these brave men and women and their families in your thoughts and prayers,” he said in an email he sent to his deputies Friday morning.

On Feb. 10, Dailey and Logsdon arrived at the Panera Bread following a complaint to police that a dangerous man was seen by his family members in the area. When the deputies approached David Evans, 68, he opened fire, killing Dailey. His partner, Logsdon, was killed during an ensuing gun battle. Evans was killed in the shootout.

Gahler said the spate of controversial fatal police shootings around the nation during the past year had caused officers to become more hesitant on the job. Now, he said, he thinks officers will become more guarded. “I think you’re going to see the other side of it, where officers have to step up that concern for their welfare,” he said.

While he said he doesn’t believe his deputies will be targeted because his department has a good relationship with Harford County, he said he is concerned about officers in other cities where relationships have been strained or fallen completely apart.

“I don’t think it’s something that my deputies particularly need to worry about, but it’s something I want them to be conscientious of,” Gahler said, “and keep their wits about them.”

Mark Berman and Julie Tate contributed to this report.