The frustration and defiance of the nation’s police officers were on display again Sunday in New York City, where tens of thousands of them gathered for the funeral of the second of two officers who were slain at the height of the ongoing protests and scrutiny after several high-profile deaths of unarmed black males.

A large number of the officers who stood under gray skies in their formal blue uniforms to honor Officer Wenjian Liu staged their own protest, turning their backs when Mayor Bill de Blasio rose to speak at the funeral.

Even some out-of-town officers joined NYPD members in the show of disrespect toward de Blasio (D), an outspoken critic of some policing tactics who has come to represent what many in law enforcement see as a lack of support, if not outright hostility, for the men and women who put their lives on the line every day to keep the streets safe.

As the nation continues to grapple with the thorny issues of race and policing, some officers have been bruised by comments made by some local and national officials and have accused them of showing more support for the protesters, some of whom have violently clashed with police, than for their police departments. Law enforcement officials say morale is flagging among the rank-and-file, who they say feel “betrayed” by President Obama and Attorney General Eric H. Holder Jr. in their calls for tough reforms of policing tactics.

“We might be reaching a tipping point with the mind-set of officers, who are beginning to wonder if the risks they take to keep communities safe are even worth it anymore,” Milwaukee County Sheriff David Clarke said. “In New York and other places, we’re seeing a natural recoil from law enforcement officers who don’t feel like certain people who need to have their backs have their backs.”

New York City Police Commissioner Bill Bratton spoke at the funeral for NYPD officer Wenjian Liu in Brooklyn Sunday. (AP)

New York became the epicenter of that frustration last month when Liu and Officer Rafael Ramos were gunned down as they sat in their patrol car on a Brooklyn street. Ismaaiyl Brinsley, who took his own life shortly after killing the officers, wrote on social media that he was avenging the deaths of unarmed black men who had been killed by police, specifically referring to Eric Garner, a Staten Island man who died in July after an officer put him in a chokehold.

When a grand jury declined to indict the officer in Garner’s death, de Blasio vowed to investigate the incident and to seek reforms in the department. He further angered some police when he said that he has warned his biracial son to take special care when interacting with officers. Tensions escalated with the deaths of Ramos and Liu. Police officers turned their backs on the mayor when he visited the hospital where the two had been taken after the shooting, and they did so again on Dec. 27 when de Blasio spoke at Ramos’s funeral as well as at Liu’s funeral Sunday.

Patrick Lynch, the president of the Patrolmen’s Benevolent Association, the city’s largest police union, spoke of “blood on many hands,” citing “the office of the mayor” and those had taken to the streets to protest Garner’s death. Other high-profile law enforcement and political figures, including former New York Police Department commissioner Bernard Kerik, former mayor Rudolph W. Giuliani and former governor George E. Pataki, took to the cable news circuit and social media to blast de Blasio, Obama, Holder and civil rights activist Al Sharpton for contributing to a climate of mistrust and hostility toward the police.

New York Police Commissioner Bill Bratton, speaking on “Meet the Press” a day after Ramos’s funeral, said the anger around policing was the “tip of the iceberg.” Asked about the role of Obama and Holder in the current climate, Bratton said officers “feel that they are under attack from the federal government at the highest level” and that it was necessary for the president and the attorney general to “see the police.”

“See why they have the anxieties and perceptions they have,” Bratton said. “We have a lot of talking we’re going to have to do here to understand all sides of the issue. This is not a one-sided issue.”

“People are responsible for their own actions,” said Lt. Lee Rankin of the Mesa, Ariz., police. “I’m sure whenever federal officials have spoken out, they have done so to try to make things better. At the end of the day, I shouldn’t, the president shouldn’t, be able to influence people to go out and commit murder.”

Still, many officers said that elected officials could have better chosen their words when responding to concerns about aggressive police tactics and should have stressed that the majority of officers are good.

Delroy Burton, chairman of the D.C. police officers union, said that Holder “gave the impression that he was against us. Like there aren’t two sides to this.” Burton said the attorney general also should have said publicly that it was important to get input from police officers when he announced in August that he was heading to Ferguson, Mo., to meet with community leaders after the police shooting of Michael Brown. The death of the teenager set off sometimes violent protests in the St. Louis suburb and drew attention nationwide.

And when Obama announced federal funding to buy body cameras for police — a step supported by many officers — Burton said the president’s tone came across as antagonistic.

“He could have said, ‘We are going to help you weed out the bad guys from your profession. We know the vast majority of you are out there doing the right thing,’ ” Burton said.

Obama has often acknowledged that point, including in an interview last month on BET when he said, “The vast majority of law enforcement officers are doing a really tough job, and most of them are doing it well and are trying to do the right thing.” He also has repeatedly said that some communities of color don’t believe they are treated fairly by police.

Several officers point to recently released data from the National Law Enforcement Officers Memorial Fund that shows an increase in the number of officers who have died in the line of duty. In 2013, there were 102 officers killed on the job. In 2014, the number rose was 126 — an increase of 24 percent increase. Ambush-style attacks were the leading cause of death in killings that happened during the commission of a felony, a total of 15.

Just one day after the two NYPD officers were killed, an officer in Tarpon Springs, Fla., was shot and killed in the line of duty.

“The recent incidents in New York and Florida are a reminder of how vulnerable members of law enforcement are simply because of the uniform we wear and that we must always remain vigilant,” said D.C. Police Chief Cathy L. Lanier. She noted that, on Christmas Eve alone, officers in the District confronted armed suspected in two separate incidents and that in October a D.C. officer was targeted in an ax attack. “We are in the midst of difficult times,” Lanier said.

Police officials in cities such as St. Louis, where protests have happened almost daily since August, say many of their officers are tired of the scrutiny and exhausted by the long hours worked to police the protests.

In response, law enforcement families in several cities have organized “Sea of Blue” and “Blue Lives Matter” demonstrations in recent weeks. More are planned in the coming months.

“There has been so much negative publicity, we wanted our officers to know that the community is behind them,” said Mary Jo Graves, a police dispatcher in Cleveland’s Brooklyn neighborhood, a west-side area that is home to scores of Cleveland police officers. On Facebook last month, Graves asked people to meet her in downtown Cleveland for a rally in support of police. She had hoped for 100 people; more than 4,000 showed up.

“I think people are finally fed up,” Graves said. “Our officers are good people who go out there to do good. Are there some things that need to be changed in law enforcement? Maybe. But it’s important that our officers know they have their community’s support.”

After the success of the Cleveland rally and march, several cities reached out to Graves about setting up similar actions.

A “Sea of Blue” march is scheduled for Jan. 17 in the District. The march, organized with Graves’s help by the wife of a D.C. officer, will go from the National Law Enforcement Officers Memorial at Judiciary Square to the Capitol.

Protesters and activists have pointed to the Obama administration’s creation of the Task Force on 21st Century Policing as a possible solution to the ongoing clashes, but some officers have expressed skepticism, noting that although it includes several police officials and police union leaders, the task force does not include any rank-and-file officers.

The administration has insisted that officers nationwide are ready and willing to conduct careful self-scrutiny and examine policing policies and practices that may have contributed to tensions.

“It’s tough right now, because obviously rank-and-file officers feel like everything is focused on them,” Ron Davis, director of the Community Oriented Policing Services Office at the Justice Department said in a call with a reporters last month. Davis is overseeing the task force.

Davis said he hopes that, by taking a heated and emotional conversation that has taken place in public and formalizing it, the task force will be able to ask tough questions and find common ground and solutions between law enforcement and the minority communities that have fueled the protests.

And despite some vocal critics of the “Black Lives Matter” demonstrations that have continued in several cities across the country, not all rank-and-file officers are offended by the protests. Officers also are split about what, if any, reforms are necessary to better police minority communities.

“You’ve got the full variety of opinions within NYPD, from zero to 100,” said Keith Santhian, who retired from the force in 2011 after 25 years. He said that officers who he has spoken with have not been unified in their views on the protests, the shootings or the clashes between de Blasio and the union.

The differences in opinion also cross racial lines, noted Santhian, who is black.

While some may expect minority officers to be more sympathetic to the protests, several he has talked to have been the most angered by them. Meanwhile, some of the white officers Santhian has spoken with have been the most adamant that police reform and improved community relations are needed.

“It’s two different police departments inside those walls,” Santhian said. “There are officers who really feel that the mayor has turned his back on the police department and that they are in increased danger. And then there are the officers who go home and tell their sons the same things that the mayor said he told his — if you’re black, be careful around police.”