Residents in Louisiana gathered to pray and mourn after a gunman killed three police officers in Baton Rouge. "It's just sad for everybody involved, all the families, the country, everything. It just needs to stop," one vigil-goer said. (Reuters)

Baton Rouge police officer Montrell Jackson had expressed the exhaustion, frustration and vulnerability of being a cop as well as any officer in these chaotic weeks.

After protests in Baton Rouge and across the country and the assault on Dallas police, he took to Facebook to describe his state of mind. “In uniform I get nasty hateful looks and out of uniform some consider me a threat,” he wrote. “I’m tired physically and emotionally.” But he continued to show up and do his job, he said, and he offered hugs to anyone who encountered him.

Responding to a call about a man with an assault weapon in Baton Rouge on Sunday morning, he was one of three officers fatally gunned down, a wrenching example of the trying times right now for law enforcement.

The hail of gunfire from one shooter and its latest casualties — three killed, three injured on Sunday — ratcheted up fears among law enforcement nationwide and brought the number of officers shot and killed in the line of duty to 30 this year, nearly double the toll at this time last year.

Police officers block off Airline Highway near the scene of a fatal shooting of police officers in Baton Rouge on July 17. (Joe Penney/Reuters)

“I’ve never experienced anything like this in my 36 years in law enforcement. That is mind-boggling to me,” said Craig Lally, president of the Los Angeles Police Protective League, a police union. “I don’t want this to become the norm. We cannot allow this to become the daily routine.”

“This is perhaps the most difficult and dangerous time in American policing history,” said Terry Cunningham, president of the International Association of Chiefs of Police. “It’s been a heartbreaking week for law enforcement, and we have to call for an end of this violence against police.”

The past two weeks have been especially deadly, with 10 officers killed — in Dallas, in a courtroom in Michigan and now in Baton Rouge.

“There is no place in the United States for such appalling violence, and I condemn these acts in the strongest possible terms,” Attorney General Loretta E. Lynch said Sunday. “I pledge the full support of the Department of Justice as the investigation unfolds.  Our hearts and prayers are with the fallen and wounded officers, their families, and the entire Baton Rouge community in this extraordinarily difficult time.”

In recent days, officers, police unions and departments have expressed sharp concern and increased fears. Police chiefs — from Washington, Boston, New York City, St. Louis, Philadelphia and Los Angeles County, among other places — ordered patrol officers to go out in pairs for their safety.

“Looking at the type of attack that happened in Dallas, a two-man car, a four-man car, a 10-man car, isn’t going to make much of a difference. But it makes the officers feel much safer,” D.C. Police Chief Cathy L. Lanier said at the time, explaining her decision.

Over the past decade, the annual number of officers killed in the line of duty has averaged about 53, with around 25 by mid-year, according to FBI data. This year was roughly in line with that average until the recent spate of fatal shootings pushed the mid-year total to 30.

Officers have described increased tension as they do their jobs, arising from heightened community suspicion and increased official scrutiny of their use of 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 people who follow and film them with cellphones while they’re working.

At a memorial on Tuesday for the five slain Dallas officers, some of the grieving officers said that they were mentally scanning and noting escape routes in case of attack — even amid Secret Service protecting the president and vice president and high security.

“It’s troubling that you had this major incident of domestic terrorism in Orlando,” said Mark Lomax, executive director of the National Tactical Officers Association. “Then three weeks later, it’s not even being talked about because of what happened in Dallas. Because of what’s happening in Baton Rouge, no one is going to be talking about Dallas. Those officers who have died, and their families, they will be thinking about what happened each and every day for the rest of their lives.”

‘I feel your pain’

Lomax was in Washington to attend a conference for the National Organization of Black Law Enforcement Executives, and he acknowledged the grievances of black communities, who have continued to protest in streets across the country against police shootings of African Americans. Many in the past two years have criticized the police response to such protests as excessive, he said. But when officers are being targeted, it makes it difficult for them to move away from using a militarized approach to law enforcement.

The recent wave of Black Lives Matter protests against excessive force began after Baton Rouge police shot and killed a man whom they had pinned to the ground outside a convenience store. Then, Baton Rouge police were criticized for responding to the protests with excessive force, sending phalanxes of officers in riot gear into the streets and arresting nearly 200 people. The American Civil Liberties Union has filed suit against Baton Rouge authorities.

“Communities and legislators say we don’t want our police to look like warriors, we want them to look like peacekeepers,” Lomax said. “But one element of war is being attacked by snipers. Now they are going to have to be properly equipped and trained to deal with this.”

The conference, attended by police chiefs from around the country, quickly turned somber as news of the Baton Rouge shooting spread.

Much of the conversation at the conference had focused on pushing for more compassionate policing. The police-involved shooting of Alton Sterling in Baton Rouge led to anger and resentment toward law enforcement, said the group’s president, Gregory A. Thomas, who added that police needed to show more understanding.

“The only way we’re going to get past this moment is if law enforcement puts their hand out and says, ‘I feel your pain,’ ” he said. “If we get a little closer to say, ‘I’m sorry, I feel your pain,’ what is the harm?”

But the shooting in Baton Rouge, he said, was “wanton, it’s heinous. . . . Have we come to this? Has it come to this?”

It remained unclear Sunday night whether the three officers killed and three injured in Baton Rouge were ambushed or whether they were responding to a shooting in progress. The July 7 Dallas shooting, however, has spawned fears of copycat incidents elsewhere.

Before Baton Rouge’s shooting, more than one-third of the slain officers this year — a total of 10 – had died in ambush attacks, concealed or unexpected assaults designed to catch law enforcement off guard. And about 20 percent of fatal police shootings over the past decade have turned out to be ambushes, according to the FBI.

On Sunday, Sheriff Jeff Wiley of Ascension Parish, which is near Baton Rouge, had strong words for the people who have expressed anti-police rhetoric in recent weeks. Wiley, whose department sent a SWAT team Sunday to back up Baton Rouge police, said in a Facebook posting: “To those who have for several years now ‘Whipped up’ a frenzy of anti-police rhetoric and repeatedly described the law enforcement and general public relationship as ‘corrosive’ and disrespectful . . . I say this to you . . . get to know these usually young men and women, look into their eyes and into their hearts before you pre-judge.”

Louisiana passed a “Blue Lives Matter” bill in May, making it the first state where targeting public safety workers such as police officers and firefighters falls under Louisiana’s hate-crime law.

“The men and women who put their lives on the line every day, often under very dangerous circumstances are true heroes, and they deserve every protection that we can give them,” Louisiana Gov. John Bel Edwards (D) said at the time.

Trying to bridge gap

Since the Dallas shooting, President Obama has tried to bridge the bitter divide between the police and the people protesting them. At the memorial service for the five officers slain in Dallas, Obama on Tuesday called for open hearts and understanding from both sides. The next day, he convened a small, closed-door summit with law enforcement leaders and Black Lives Matter activists. On Thursday, he tried to bring that conversation public with a prime-time televised town hall meeting.

At the event, which focused on race and policing, Obama offered suggestions and asked for mutual understanding. But he acknowledged there were no easy solutions.

Cunningham, police chief in Wellesley, Mass., attended both of last week’s meetings with Obama.

“Wherever you come down in your politics, we have to call for the end of violence against police,” he said Sunday. “You have to think of the cumulative effect on officers every day. It’s demoralizing to them. That constant stress has to be wearing them down.”

After Dallas, the national outpouring of grief and the meetings convened by Obama, Cunningham said he had felt hopeful. Now, after Baton Rouge, he said, he mainly felt even greater determination to try to unite police with at times sharply critical communities.

“My heart is broken over what happened. And it increases my resolve for us to do what we need to do to bridge this divide,” he said. “The bottom line is, if we don’t work to resolve this issue, we’re going to see more officers die. So we have to find a path forward.”

Faiz Siddiqui and Wesley Lowery contributed to this report.