The killing of five police officers in Dallas and the police shootings of black men in Baton Rouge and Minnesota are thrusting Mayor Bill de Blasio into the forefront of a national debate around race and policing, an issue he is uniquely positioned to lead on, but he is treading carefully after facing an earlier backlash from the NYPD. NY1's Grace Rauh filed the following report.

After five police officers were gunned down in Dallas, Mayor Bill de Blasio stood in solidarity with officers across the country, and in Dallas in particular.

"An attack on our police is an attack on all of us," de Blasio said. "These police officers were there for the people around them, and they were protecting the protesters, even as these bullets were hailing down."

A day earlier, the mayor, unprompted, spoke out about the deaths of two black men killed at the hands of police. He said he was reeling from having seen videos of them dying.

"No parent of color, or a parent of a child of color, in this country can watch that and not be afraid," he said. "You fear for the life of a child when you see a situation like this."

It was one of the more forceful statements the mayor has made about racial bias in policing in the last year and a half. He's been trying to walk a fine line since he came under fire from police for talking about teaching his biracial son, Dante, how to interact safely with police officers.

"We have had to literally train him, as families have all over this city for decades, in how to take special care in any encounter he has with police officers who are there to protect him," de Blasio said.

After those remarks, officers turned their backs on the mayor in a stunning open revolt.

De Blasio entered City Hall as a police reformer. He's had officers trained in de-escalating tense confrontations, and he supports the use of body cameras. But his commitment to cracking down on low-level crimes, a practice known as broken windows policing, has alienated some New Yorkers who were previously in his corner, like many of those taking to the streets to protest. On Friday, de Blasio had a message for them.

"Show respect for the officers who are protecting you," he said.

For now, the mayor is trying to keep the peace within the city and within the police department as well.