The ambush killing of two New York police officers Saturday has forced a burgeoning protest movement over police use of lethal force to address accusations that it bears some responsibility for violence carried out in the name of that cause.

Officers Wenjian Liu and Rafael Ramos were fatally shot Saturday as they sat in their patrol car in a Brooklyn neighborhood. The suspect, 28-year-old Ismaaiyl Brinsley, is thought to have posted threats against police on social media before shooting his ­ex-girlfriend in Baltimore and then traveling to New York to target the officers. He killed himself soon after attacking the officers.

Police officials in New York and elsewhere were quick to lay at least partial blame for the officers’ killings on ongoing protests of several high-profile fatal encounters between police and unarmed black men this year. Brinsley referred to two of those men in his online rants.

“Let’s face it: There’s been, not just in New York but throughout the country, very strong ­anti-police, anti-criminal-justice system, anti-societal initiatives underway,” New York Police Commissioner William J. Bratton said during a news conference Saturday. “One of the unfortunate aspects sometimes is some people get caught up in these and go in directions they should not.”

The officers’ deaths were condemned by local, state and national officials; the families of the victims of police killings this year; and many of the civil rights leaders and groups that have been the most vocal in the ongoing national Black Lives Matter protests.

“I’m standing here in sorrow about losing those two police officers,” said Gwen Carr, the mother of Eric Garner, whose ­video-recorded chokehold death at the hands of a New York officer this year sparked national outrage that turned to protest when the officer was not indicted. “These two police officers lost their lives senselessly.”

But pundits, particularly among political conservatives and law enforcement officials — who for weeks have insisted that the demonstrations are ­“anti-police” — said this weekend that the attack on the two officers was a result of the tense environment created by the protests.

“There’s blood on many hands tonight — those that incited violence on the street under the guise of protest, that tried to tear down what New York City police officers did every day.” Patrick J. Lynch, president of the Patrolmen’s Benevolent Association in New York, a union representing the city’s police officers, declared during a news conference Saturday night.

Lynch said he also personally holds Mayor Bill de Blasio responsible. His union alleges that the mayor has not been supportive of police officers in recent months.

Within an hour of the shooting, many protest organizers had begun text-message and ­e-mail discussions of how best to handle their public response.

By nightfall, two unsigned statements had been released, one by Ferguson Action, an umbrella group that represents protesters in Ferguson, Mo. — where Michael Brown, an unarmed black teenager, was fatally shot by a white police officer in August — and another on behalf of the broader Black Lives Matter protests.

“Today’s events are a tragedy in their own right,” the Ferguson Action statement said. “To conflate them with the brave activism of millions of people across the country is nothing short of cheap political punditry.”

In statements, social media postings and interviews, various protest leaders struck a unified message when addressing the New York shootings. They emphasized that the killings were tragic and not linked to the protests, they said the news media had glossed over the fact that the suspect shot his former girlfriend, and they pointed to their repeated public calls advocating nonviolence.

“We’ve all said that this is a horrible thing that shouldn’t have happened,” said Charles Wade, a leading protest organizer. “I say time and time again that I’m against police violence, and I’m not against police officers in general. I have an issue with improper policing, police violence and police impunity.”

The Black Lives Matter movement — which is propelled by a diverse set of local grass-roots organizations that have eschewed the suggestion that they appoint a national leader or spokesman — has long grappled with how best to handle acts of violence carried out by those claiming to be in solidarity with the protests.

The New York shooting also diverted attention from what organizers consider one of their most successful weekends of protest, with demonstrations in Cleveland and at the Mall of America in Minnesota drawing hundreds.

Organizers also are cautious of appearing defensive in the wake of the shootings.

“If we talk about it too much, then people draw more of an association than needs to be drawn,” said Wade, who is in Cleveland helping coordinate the protests. “You don’t out-defend a lie; you outlive it. We have to carry out the work that we set out to do.”

The Rev. Al Sharpton was quick to condemn the killings, too, and has noted in previous interviews that he vets speakers at any march he holds to sift out any advocate for violence. Sharpton’s role as an adviser to the families of Garner and Brown, has meant that his history of activism — and the sometimes divisive baggage that accompanies his name — has been linked to the Black Lives Matter demonstrations.

“From the beginning, we have stressed that this is a pursuit of justice to make the system work fairly for everyone,” Sharpton said Saturday, adding that he and the Garner family have received threats in the hours since the New York officers were killed. “This is not about trying to take things into our own hands. That does not solve the problem of police brutality.”

Still, the frequent and leaderless protests in many cities have given a stage to those who advocate violence against police. On several nights in Ferguson, groups pushing for armed confrontations threatened police officers and their families. In a video clip that has been widely circulated on conservative blogs, demonstrators at a recent protest in New York City chanted: “What do we want? Dead cops!”

The march was one of the smallest of the dozens that have taken place in New York in recent weeks, and protest leaders say attempts to tie the relative few advocating violence — as well as the New York shooting — to the broader demonstrations are unfair.

“This wasn’t at all related to protests. This wasn’t some revolutionary act,” Cherrell Brown, an organizer who has been instrumental in the New York protests, said during an appearance on MSNBC on Sunday morning. “This was a senseless murder.”

Many of the most visible protesters in Ferguson spent weeks in meetings with law enforcement and local officials ahead of the grand jury decision not to indict Darren Wilson, the officer who fatally shot 18-year-old Brown.

“None of us want to see this city burn,” DeRay Mckesson, one of the leaders of the Ferguson protesters, said at the time.

But privately, most of the Ferguson organizers acknowledged that there was little they could do to stop violence in the event that Wilson was not indicted. On the night of the grand jury decision, most of the protest leaders watched the announcement from an apartment in downtown St. Louis and hours later held a march within the city limits.

Meanwhile, in suburban Ferguson, dozens of buildings were looted and burned in leaderless riots.

Mckesson and other organizers were attacked on social media by angry commentators, who suggested that they were to blame for the shootings of the New York officers. Mckesson responded with what would be the first of dozens of carefully crafted tweets.

This one was retweeted more than 8,000 times: “I do not condone the killing of the two NYPD officers today. I do not condone the killing of unarmed black people. I do not condone killing.”

Mckesson added in his next dispatch: “See, life is a beautiful thing. And we can live in and create a world where no one is killed.”