Thousands of police officers have gathered in New York City for the funeral of a slain comrade Wenjian Liu, with some repeating a protest act of turning their backs to Mayor Bill de Blasio.

Liu, 32, and his partner Rafael Ramos, 40, were killed on December 20 by a man who posted social media messages threatening to take revenge over the murder of unarmed black men by police officers.

Al Jazeera's Courtney Kealy, reporting from outside Aievoli Funeral Home in Brooklyn, said Sunday's occasion was particularly sombre and heart-breaking.

"There were a small group of officers and firemen that turned their backs," she said. "But I stress it was not the majority that did so."

She said that Liu, who had chosen to become a police officer after the September 11, 2001, attacks, was the first Chinese American officer to be laid to rest and that the funeral, including a private Buddhist ceremony, reflected New York City's cosmopolitan character.

'American story'

De Blasio told the mourners on Sunday that Liu's story was a powerful American story.

"It is such a classic New York story," he said. "A young man who came here from China with his parents at the age of 12 in search of the American dream, in search of the dream that generations have come to New York to find."

The build-up to Liu's funeral had been dominated by speculation over whether officers would stage a repeat of their protest at Ramos's service last week, when hundreds turned their back on de Blasio.

De Blasio has come under fierce criticism from officers and political opponents for his remarks about police relations with black Americans that they say incited the shooting, particularly that he counsels his biracial son to be particularly careful around police officers.

New York Police Commissioner Bill Bratto had urged officers not to repeat the protest at Liu's service, arguing that it deflected attention away from the focus of the funeral.

"A hero's funeral is about grieving, not grievance," Bratton wrote in a memo to 34,000 New York police officers.

Source: Al Jazeera and agencies