Former New York Police Commissioner Ray Kelly has slammed New York Mayor De Blasio for creating an anti-cop environment in New York after two policemen were shot dead by a crazed gunman

The gunman stated on Instagram he was seeking revenge for the recent killings of African Americans Eric Garner and Michael Brown.

"Quite frankly, the mayor ran an anti-police campaign last year when he ran for mayor,” Kelly told ABC.

“Obviously, there's a lot of emotion involved when two police officers are killed," Kelly said. "When the mayor made statements about how they had to train his son, who is biracial, to be careful when he’s dealing with the police, I think that set off this latest firestorm."

"You're talking about his opposition to stop and frisk," ABC host George Stephanopoulos asked Kelly. "Is that what you think was anti-police?"

“I think a lot of the rhetoric was -- at a time when the police had a 70 percent approval rating," Kelly stated. "Obviously that’s not the case now."

Irish American Ray Kelly was police commissioner twice both under Mayor David Dinkins and Michael Bloomberg. He played a huge role in the massive decline in crime in the city.

But Kelly had been castigated by incoming Police Commissioner Bill Bratton when he took over under de Blasio, so his comments on Sunday could be seen as a payback.

At the time he took over Bratton stated: “Morale coming into this department was awful. The public didn’t understand that, politicians didn’t understand it, but it was a very dispirited organization. It was an organization, I think, beat down over several years, beaten up by the political establishment during Kelly's watch.”

“The commissioner and the former mayor did a great job in the sense of keeping the community safe, keeping crime down, but one of the tools used to do that, I believe, was used too extensively,” said Bratton, referring to stop and frisk.

“Quite clearly, the legacy of that era is now going to be the inspector general . . . a federal monitor . . . an enlarged Civilian Complaint Review Board,” Bratton told WABC’s Diana Williams.

Kelly’s comments on De Blasio echoed hardline statements by the top cop union official.

"There's blood on many hands tonight," Patrolman's Benevolent Association President Patrick Lynch said on Saturday. "Those that incited violence on this street under the guise of protest, that tried to tear down what New York City police officers did everyday.

"We tried to warn it must not go on, it cannot be tolerated," Lynch continued. "That blood on the hands starts on the steps of city hall in the office of the mayor."

Kelly stated such targeted cop killings had happened before, "We have a history in this city, in the 70's, of these sorts of assassinations of teams of police officers and we saw more coming down the pike," said Kelly. "Actually, in 1972, there were 12 police officers killed."

Kelly said that "we don't know" if Saturday's shooting will lead to copycat attacks.

"I think cooler heads will prevail. As I said, there was a lot of emotion last night," Kelly said. "You may see a little of that early on here ... but I think that will cool down pretty quickly."

"I've never seen officers back off from their sworn duty," he said.