Media playback is unsupported on your device Media caption Mia Hunt-Pierce sang the national anthem during the service as thousands of police officers watched outside

Tens of thousands of people are attending the funeral in New York of Rafael Ramos, one of the two policemen shot dead a week ago.

Vice-President Joe Biden praised the "finest police department in the world" at the service, attended by police forces from across the US and Canada.

Mr Ramos and Wenjian Liu were shot after weeks of anti-police protests.

Police at the funeral again snubbed New York Mayor Bill de Blasio, who had appeared to back some of the protests.

Funeral details for Officer Liu have yet to be announced. Officials say it will be held when relatives arrive from China.

Media playback is unsupported on your device Media caption Vice-President Joe Biden says Rafael Ramos "was a cop for all the right reasons"

Telling the mourners Officer Ramos had been a "hero", Police Commissioner Bill Bratton announced he had promoted both officers posthumously to Detective First Grade.

New York Governor Andrew Cuomo also paid tribute to the dead officer as well as to the New York Police Department (NYPD).

'It affects everyone'

"I believe that this great police force of this incredibly diverse city can and will show the nation how to bridge any divide," Vice-President Biden told the congregation at the Christ Tabernacle Church in Queens.

"You've done it before and you will do it again."

Officer Ramos, 40, had been studying to become a police chaplain and was described as "a man of great faith" by a pastor who knew him.

Commissioner Bratton, his voice choking with emotion, said: "Rafael Ramos was assassinated because he represented all of us."

Image copyright AP Image caption Police helicopters flew in formation over the funeral procession

Image copyright Reuters Image caption Police saluted the hearse

Image copyright AFP Image caption Ramos family members were comforted when they arrived for the funeral

Image copyright Getty Images Image caption Emotions ran high among the police officers in attendance

Image copyright Reuters Image caption A painting of Officer Ramos could be seen at the church

Image copyright Getty Images Image caption Police from all over the US came to the funeral

Image copyright Reuters Image caption Canadian Mounties attended the funeral too

The two police officers had been killed by a "madman", he continued, who had only been able to see two uniforms, not the people wearing them.

New York Governor Andrew Cuomo told mourners he had watched recent protests and seen "people hurling insults" directly in the face of the police officers, but the police continued doing their jobs.

When the Ramos family arrived for the service, the eldest son Justin, wearing his father's NYPD jacket, was hugged by a police officer. The policeman is also survived by his younger son Jaden and his wife Maritza.

Officer Dustin Lindaman of the Waterloo Police Department had flown from Iowa to attend the funeral.

"He's one of our brothers and when this happens, it affects everyone in law enforcement - it absolutely affects everyone," he told the Associated Press news agency.

History of violence

Inside the church, Mr de Blasio's speech was met by polite applause but outside, police officers could be seen turning their backs when he appeared on a giant video screen.

Image copyright Reuters Image caption Officers turning their backs on the mayor

The mayor had been snubbed in a similar manner by officers at the hospital where the two men were pronounced dead on 20 December.

The two police officers were shot following weeks of protests over several killings of unarmed black men by white police officers.

In New York, a grand jury decided not to press charges against a white police officer over the death of unarmed black man Eric Garner, who was placed in a chokehold while being restrained by New York police officers.

Commissioner Bratton has said he strongly rejects the notion that Mayor de Blasio increased the risk to police officers by appearing to side with protesters following the death of Mr Garner.

Media playback is unsupported on your device Media caption Police Commissioner William Bratton: "He was a New Yorker. He was a New York City police officer. And he was - he is - a hero"

Black man Ismaaiyl Brinsley, 28, shot and killed officers Ramos and Liu as they were sitting in a patrol vehicle in the borough of Brooklyn. He then killed himself nearby.

Brinsley had a history of violence and mental instability and had been arrested at least 19 times in Georgia and Ohio, police said. Before attacking the police officers, he had shot and injured his girlfriend.

On the day of the shooting, he went on social media to say he was planning to kill police officers.