Thousands of police officers from across the country assembled in winter sunshine in New York City for the funeral of Rafael Ramos, a police officer shot to death with his partner in an ambush last week.

The officers in dress blue uniforms stood outside the Christ Tabernacle Church in Queens for the Saturday morning services. The sea of blue stretched more than six city blocks.

In his eulogy, Mayor Bill de Blasio offered the city's condolences to the Ramos family.

"All of this city is grieving and grieving for so many reasons," he said. "But the most personal is that we lost such a good man."

Vice-President Joe Biden expressed his condolences to Ramos two sons.

“You’ve shown tremendous courage these past days,” he said. He also said to Ramos' widow, "I speak for the whole nation when I say our hearts ache for you." 

He said Ramos and his partner Wenjian Liu were two officers who were committed, passionate, vigilant.

“Being a cop was not what they did, it was who they were like every man and woman in uniform today and they, like every one of you here and outside, they all joined for the same reaons,” Biden said.

The church applauded when Biden said the NYPD was probably the finets in the world.

“I believe this police force will show the nation how to bridge any divide,” the vice-president said.

The mourners in blue began showing up at the church early.

"He was studying to be a pastor. He had Bible study books in his locker, which is rare for a police officer, but that goes to show you the type of man he was," NYPD Capt. Sergio Centa said before entering the church.

WATCH FUNERAL SERVICE LIVE 

"Law enforcement isn't just your own department; it runs deep," said Lt. Chris Thibault of the Ridgefield Park, New Jersey, Police Department.

When the Ramos family arrived, the eldest son -- wearing his father's New York Police Department jacket -- was hugged by a police officer.

Funeral plans for his partner, Officer Wenjian Liu, have yet to be announced.

The officers were killed Dec. 20 while sitting in their patrol car on a street in Brooklyn's Bedford-Stuyvesant section. Investigators have said the gunman, Ismaaiyl Brinsley, was troubled and had shot and wounded an ex-girlfriend in Baltimore earlier that day.

Ramos was described Friday during an eight-hour wake as a selfless, caring and compassionate man.

"What happened to my father was a tragedy," Ramos' son, Justin, said in a tearful eulogy viewed by hundreds of officers in the street who watched on giant television screens outside the crowded church. "But his death will not be in vain."

Ramos, a 40-year-old married father of two, was studying to become a pastor and kept Bible study books in his locker, his commanding officer said.

Officer Dustin Lindaman of the Waterloo Police Department flew from Iowa to attend Ramos' funeral.

"He's one of our brothers, and when this happens, it affects everyone in law enforcement -- it absolutely affects everyone," he said. "We wanted to show our support."

The man who killed Ramos and his partner committed suicide soon after the shooting. In online posts shortly before the attack, Brinsley referenced the killings of two unarmed black men -- Michael Brown in Ferguson, Missouri, and Eric Garner on Staten Island -- by white police officers.

Police union officials have said de Blasio contributed to a climate of mistrust toward police amid protests over the deaths of Brown and Garner. At a hospital after the shooting, the police union's president, Patrick Lynch, and others turned their backs on the mayor in a sign of disrespect. Lynch blamed the mayor then for the officers' deaths and said he had blood on his hands.

Weeks before the shooting, Lynch suggested that officers sign a petition requesting that the mayor not attend their funerals were they to die in the line of duty.

Cardinal Timothy Dolan and others have since tried to temper the rhetoric.

De Blasio has stood firmly by the police since the shooting, calling on the demonstrators to temporarily halt their protests and praising officers after the police department announced the arrest of a seventh person since the shooting for making threats against police.

On Friday, the mayor briefly attend Ramos' wake but made no comments. There was no noticeable reaction from officers upon his arrival, and Ramos' family has said they welcome the mayor's presence at the funeral.

There was no noticeable reaction from police outside the church when de Blasio arrived Saturday about a half hour before services.

A block from the church, though, retired NYPD Officer John Mangan held a sign that read: "God Bless the NYPD. Dump de Blasio."

"If the mayor really wanted to do the right thing, he would have gotten into an NYPD car and rode around Bed Stuy and see the difficult jobs these cops do every day," Mangan said. "The bottom line is there should be more signs out here in support of these cops."

Ramos and Liu were the first officers to die in the line of duty in New York since 2011.

They have both been posthumously promoted to first-grade detective, police said.

The Associated Press contributed to this report