Thousands of police officers packed rain-swept streets on Wednesday, remembering a slain New York Police Department officer — a "hero" whose commitment to policing the city's police commissioner says should serve as an example for all New York officers.

As Officer Randolph Holder's coffin was wheeled inside a Queens church, the hundreds of officers who sat shoulder-to-shoulder saluted. Outside, thousands more saluted their fallen comrade, as they lined up 10 and 20 deep.

"All of New York City is in pain at this moment," Mayor Bill de Blasio said in his eulogy. "We know our city lost a remarkable man; a man who made it better by his presence."

Before de Blasio delivered the eulogy, he paused in front of the coffin in the front of the Greater Allen A.M.E. Cathedral of New York. Afterward, he shook hands with Holder's parents and kissed the 33-year-old officer's fiancee.

The mayor spoke of how Holder came to the United States 12 years ago with his lifelong dream of becoming a police officer — like his father and grandfather had in Guyana — and "make the world better."

Holder "served as a peace officer in the truest sense of the word," the mayor said. "He loved to be in the community. He loved to connect to the people around him."

As a mourner sang "Amazing Grace," Holder's stepmother, Princess Holder, rocked slowly back and forth in her husband's arms as she wept and sobbed. At one point, she whaled, "Why?" as tears streamed down her face.

Holder, a five-year veteran, was killed Oct. 20 while responding to a report of shots fired and a bicycle stolen at gunpoint in Manhattan's East Harlem neighborhood. Authorities have accused Tyrone Howard of hopping off the stolen bicycle and shooting Holder in the head. His attorney has said there are missing details in the case.

When he got the call, Holder and his partner "went toward the danger. They didn't pull back," Police Commissioner William Bratton said. "Why? It's what we do ... In Guyana or Harlem. It's what we do."

Bratton posthumously promoted Holder to detective and issued him a new gold shield with No. 9657 — the same number of the badge worn by his father, Randolph Sr. The elder Holder hugged Bratton before slowly bowing his head to admire the shield, as mourners erupted into applause.

"Detective Randolph Holder, you are relieved of your duty as a New York City police officer, a guardian at the gates of New York City," Bratton said. "... And we send you on your new assignment to be a guardian angel at the gates of heaven."

Holder's fiancee, Maryiane Muhammad, told the grieving congregants that his death was teaching her a painful lesson in courage.

"To simply wear the uniform of an officer is an act of courage," she said. "You have chosen to be both target and hero. It could be argued that to the loved one of an officer, we chose the same fate."

Holder is to be buried later this week in Georgetown, Guyana.