NEW YORK -- Hours after two New York police officers were shot and killed while on duty in Brooklyn Saturday, the head of New York City's police union blasted Mayor Bill de Blasio and those who have recently protested against incidents of police violence.

"There's blood on many hands tonight," Patrolmen's Benevolent Association President Patrick Lynch told reporters outside the hospital where officers Wenjian Liu, 32, and Raphael Ramos, 40, died.

New York police officers Wenjian Liu (left), 32 and Rafael Ramos, 40, were shot and killed while on duty Saturday, Dec. 20, 2014 in Brooklyn, New York. New York Police Department

"Those that incited violence on the streets under the guise of protest that tried to tear down what New York City police officers did every day. We tried to warn it must not go on, it cannot be tolerated," Lynch said. "That blood on the hands starts at City Hall in the office of the mayor."

Get Breaking News Delivered to Your Inbox

Lynch and de Blasio have been locked in a public battle over treatment of officers following the decision not to indict an NYPD officer in the chokehold death of Eric Garner in July. Just days ago, Lynch suggested police officers sign a petition that demanded the mayor not attend their funerals should they die on the job.

Demonstrators around the country have staged die-ins and other protests since a grand jury decided Dec. 3 not to indict the officer involved in Garner's death, a decision that closely followed a Missouri grand jury's decision not to indict a white officer in the fatal shooting of Michael Brown, an unarmed black 18-year-old.

Several New York officers were assaulted during a demonstration that drew thousands to the Brooklyn Bridge last weekend, although the protests have been largely been peaceful. Three people have been arrested in the assault; four other suspects remain at large.

"New York City police officers through this sadness will strengthen their shoulders, stiffen their backs and mourn for these families," Lynch said. "We will mourn for our city and we will mourn for our brothers. When these funerals are over, those responsible will be called on the carpet and held accountable."

The mayor's office issued a statement responding to the PBA Saturday night, CBS New York reported.

"It's unfortunate that in a time of great tragedy, some would resort to irresponsible, overheated rhetoric that angers and divides people," the statement said. "Mayor de Blasio understands this is the time when we must come together to support the families and friends of those brave officers New York City lost tonight -- and the entire NYPD community."

Others took to social media to place blame on the mayor.

The Sergeants Benevolent Association tweeted: "The blood of 2 executed police officers is on the hands of Mayor de Blasio. May God bless their families and may they rest in peace."

The blood of 2 executed police officers is on the hands of Mayor de Blasio. May God bless their families and may they rest in peace. — SBA (@SBANYPD) December 21, 2014

Former New York Gov. George Pataki tweeted: "Sickened by these barbaric acts, which sadly are a predictable outcome of divisive anti-cop rhetoric of #ericholder & #mayordeblasio. #NYPD"

Sickened by these barbaric acts, which sadly are a predictable outcome of divisive anti-cop rhetoric of #ericholder & #mayordeblasio. #NYPD — George E. Pataki (@GovernorPataki) December 21, 2014

The hashtag #NYPDLivesMatter was trending nationwide on Twitter. In recent weeks, people used the hashtag #BlackLivesMatter to express outrage over the killings of unarmed black men by police officers and to organize rallies and protest marches.

New York State Sen. Greg Ball posted a statement on Facebook that said, in part, "Today, our NYPD and other law enforcement and emergency responders have walking targets on their backs and are in grave danger. Mince no words. The Mayor is directly responsible for their safety or lack thereof."

Congressman Peter King said it was "time for elected officials to stand by the men and women of law enforcement and end the demeaning of police officers and grand juries."

Police said the suspect, 28-year-old Ismaaiyl Brinsley, approached the passenger window of a marked police car Saturday afternoon and opened fire, striking Ramos and Liu in the head.

"They were, quite simply, assassinated -- targeted for their uniform," Police Commissioner Bill Bratton said at a news conference Saturday evening announcing the officers' deaths. "They were ambushed and murdered."

After shooting the officers, Brinsley ran into a nearby subway station and killed himself. The gunman had made online posts that were "very anti-police," Bratton said.

"It is an attack on all of us. It is an attack on all that we hold dear," de Blasio said, urging the public to come forward and immediately report any threats or possible attacks against law enforcement.

"Everybody is feeling different things but I don't think anybody in their right mind called for the death of an officer," Brooklyn City Councilman Robert Cornegy said at the crime scene Saturday. "People are frustrated with the results of Staten Island and Eric Garner, but I don't think I know anyone in this community that would agree with taking the lives of an officer."

Civil rights leader Rev. Al Sharpton, who has helped organize some of the demonstrations against police brutality, released a statement denouncing the killings.

"Any use of the names of Eric Garner and Michael Brown, in connection with any violence or killing of police, is reprehensible and against the pursuit of justice in both cases," Sharpton said. "We have stressed at every rally and march that anyone engaged in any violence is an enemy to the pursuit of justice for Eric Garner and Michael Brown."

Tony Herbert, a community activist who often speaks out on policing issues, went to the area near the shooting to express his outrage at the killings and support for police.

"We've been denouncing violence in our community," no matter whom it's directed at, he said. He's concerned that some "agitators" might seek to cast the shooting as an outcome of amid the anger over Garner's death.

"It sullies the opportunity for us to make inroads to build the relationships we need to build to get the trust back... This hurts," Herbert said, shaking his head.