The streets of this working-class neighborhood in Queens overflowed on Saturday with thousands of blue-uniformed police officers, state troopers, corrections officers and firefighters from across the country.

A Louisiana sheriff walked the city streets in a cowboy hat. A police car from Anne Arundel County, Md., rolled past pizza shops and Polish butchers.

Wearing white gloves and with black tape across their badges, they came to attend the funeral of New York City police officer Rafael “Ralph” Ramos, 40, who was gunned down with his partner, Wenjian Liu, 32, exactly one week before in Brooklyn as the pair sat in their squad car.

The outpouring — some estimates were of more than 20,000 officers — was about more than brotherhood and the New York Police Department’s long history of showing support to honor slain officers. This time, the solemn memorial turned into a kind of counterprotest.

It was their turn to raise their voices, they said, after months of demonstrations over police tactics following the August shooting death of unarmed African American teen Michael Brown in Ferguson, Mo., and a New York grand jury’s decision not to indict an officer in the July chokehold death of African American Eric Garner on Staten Island.

New York's Empire State Building was lit up in blue to honor the two NYPD officers killed in Brooklyn last week. (Reuters)

“Today is our chance to show our side of things,” said Tom Sebasty, former president of the New Jersey police Honor Legion.

Vincent DeMaio, a police officer who stood outside the church, said he hoped people would try to understand how hard and how dangerous being a police officer can be.

“Everyone has been protesting that they are targeted, but this tragedy just goes to show society that sometimes it’s the other way as well,” he said. “We feel targeted, too. All they did wrong was sit in that police car. And they got killed for it.”

Brown and Garner’s killings sparked a nationwide protest movement and debate about the treatment of African Americans by law enforcement, with social-media slogans such as “Black lives matter” and “I can’t breathe,” Garner’s last words.

After “respecting First Amendment rights and handling false and abusive insults,” as Gov. Andrew M. Cuomo (D) put it during his remarks at the funeral, it was police officers’ time to be heard.

And, in one tense gesture, seen.

Hundreds of officers watching the services outside Christ Tabernacle Church turned their backs on the screens when Mayor Bill de Blasio spoke. The mayor has been heavily criticized by New York police union officials, accused of causing a mood of mistrust that they say contributed to the killings of Ramos and Liu. Tensions between the mayor and police had already grown in recent months after de Blasio said he was worried about how police might treat his son, who is biracial.

NYPD helicopters performed a synchronized flyover over New York on Saturday, in a tribute to their fallen colleague, Officer Rafael Ramos. (The Washington Post)

Vice President Biden, who attended the funeral, promised that the “incredibly diverse city can and will show the nation how to bridge any divide.”

New York City Police Commissioner William J. Bratton called Ramos “a hero” and gave the officer and his partner posthumous promotions, which will boost the department’s financial benefits to their families. He had words of hope for a way forward.

“If we can learn to see each other,” Bratton said, “to see that our cops are people like Officer Ramos and Officer Liu, to see our communities filled with people like them, too — if we can learn to see each other, then when we see each other we’ll heal.”

Still, unease and uncertainty filled the air.

One man held a sign reading “God Bless the NYPD” and “Dump DeBlasio.”

A group of police spouses gathered and said the show of support was a sort of release after watching month after month of protests directed at police.

“You think about how people just hate your husband for what he does,” said Lisa, who wanted to give only her first name. She is also training to be a police officer, “because I want to protect and serve my city,” she said.

But she said she feels for the families of Brown and Garner, too.

“I was raised in the projects. I get it,” she said. “But I feel like the department and police generally are being blamed for racial problems that are much deeper.”

Ismaaiyl Brinsley, the man who police say shot Ramos and Liu as they sat in their patrol car before killing himself, had promised on social media to put “Wings On Pigs.”

He had vowed revenge over the police actions in Ferguson and Staten Island.

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

Ramos was a one-time teenage graffiti artist who was known to his childhood friends by a nickname that translates to “can of goodness.” He became a school safety officer and then a policeman. Ramos was studying to become a lay chaplain in the weeks before his death.

Bratton told mourners he had named Ramos an honorary chaplain of the 84th Precinct, where he and Liu were stationed.

Ramos did not fit the stereotype of the white officer acting aggressively toward African Americans, an issue at the center of recent protests, said Deacon John Cortes, a longtime friend of Ramos’s.

“He was a Puerto Rican kid who grew up on these streets,” he said. “This was a man who worked in our marriage ministry, counseling other young couples. He would say: ‘If you have an argument, just be kind. Don’t fight.’ ”

On Saturday, Ramos’s widow, Maritza, held the flag that had draped her husband’s coffin. His older son, Justin, touched it and his mother’s hand repeatedly, shaking while he tried to hold back tears.

As Ramos’s casket moved through the sea of officers to the sound of bagpipes after the ceremony, many lowered their eyes and some raised their badges.

Others wept behind sunglasses. The silence was pierced when police helicopters flew in formation over the procession.

Lenny Bernstein in Washington contributed to this report.