The show of disrespect came outside the funeral home where Officer Wenjian Liu was remembered as an incarnation of the American dream: a man who had emigrated from China at age 12 and devoted himself to helping others in his adopted country. The gesture among officers watching the mayor’s speech on a video screen added to tensions between the mayor and rank-and-file police even as he sought to quiet them.

“Let us move forward by strengthening the bonds that unite us, and let us work together to attain peace,” de Blasio said.

Liu, 32, had served as a police officer for seven years and was married just two months when he was killed with his partner, Officer Rafael Ramos, on Dec. 20. Liu’s longtime aspiration to become a police officer deepened after the Sept. 11 terror attacks, his father, Wei Tang Liu, said through tears.

He recalled that as his son finished his daily work, he would call to say: “I’m coming home today. You can stop worrying now.

Dignitaries at the funeral, which blended Buddhist ceremony with police trappings, including FBI Director James Comey and members of Congress, as well aspolice officers from around the country.

“When one of us loses our lives, we have to come together,” said Officer Lucas Grant of the Richmond County Sheriff’s Office in Augusta, Ga.

After hundreds of officers turned their backs to a screen where de Blasio’s remarks played during Ramos’ funeral last week, Police Commissioner William Bratton sent a memo urging respect, declaring “a hero’s funeral is about grieving, not grievance.”

But some officers and police retirees said they still felt compelled to spurn the mayor. Police union leaders have said he contributed to an environment that allowed the officers’ slayings by supporting protests following the police killings of Eric Garner on Staten Island and Michael Brown in Ferguson, Mo.

“The mayor has no respect for us. Why should we have respect for him?” said retired New York Police Department Detective Camille Sanfilippo, who was among those who turned their backs Sunday.

Officers spun back around when Bratton took the podium to speak. Later, de Blasio stood outside the funeral home, to no visible reaction from officers, observing an honor guard and other rituals.

At Liu’s wake Saturday, Gov. Andrew Cuomo called the officers’ slayings a tragic story of “pure and random hatred.” Cuomo didn’t attend the funeral, which came as he prepared to bury his father, former Gov. Mario Cuomo.

The officers’ killer, Ismaaiyl Brinsley, committed suicide shortly after the brazen daytime ambush on a Brooklyn street. Investigators say Brinsley was an emotionally disturbed loner who had made references online to the killings this summer of unarmed black men at the hands of white police officers, vowing to put “wings on pigs” in retaliation.

The deaths strained an already tense relationship between city police unions and de Blasio. Patrolmen’s Benevolent Association President Patrick Lynch, whose rank-and-file union is negotiating a contract with the city, turned his back on the mayor at a hospital the day of the killings and said de Blasio had “blood on his hands.”

Many people, including Cardinal Timothy Dolan, have since pressed all parties to tone down the rhetoric. On Saturday, officers standing outside Liu’s wake saluted as the mayor and commissioner entered.

After Sunday’s show of disdain, Lynch said officers “have a right to have our opinion heard, like everyone else that protests out in the city” and noted that officers’ “organic gesture” was outside the service. The mayor got a respectful reception among police officials inside.

The NYPD declined to comment, and de Blasio spokesman Phil Walzak said the mayor was focused on honoring the fallen officers.