NEW YORK — It was just after 9 a.m., and dozens of police officers were huddled under the elevated subway tracks on New Utrecht Avenue in Bensonhurst, taking refuge from a pelting rain that fell steadily from the gray skies of Brooklyn on Sunday.

They had made the long trek from California, from Illinois, from Canada and elsewhere because they had lost a fellow cop. But for many of these officers, the loss was even more personal, even more acute, because the story of the fallen cop, New York police Detective Wenjian Liu, was also their own story.

"When we saw the spelling of his name, we knew he was from mainland China, and we knew we had to go," said Toronto police Constable Qian L. Yang, an immigrant from central China who serves as the Toronto Police Service's liaison to the city's Chinese community. "We have the same background, the same culture. We wanted to show our respect."

Yang, 44, was one of thousands of mourners from near and far — many of them Chinese-American — who lined 65th Street outside Aievoli Funeral Home in Brooklyn, where funeral services were held for Liu, who was shot to death along with his partner, Officer Rafael Ramos, as they sat in their squad car Dec. 20 in Bedford-Stuyvesant in Brooklyn.

Liu's funeral came a week after Ramos was laid to rest in Queens in a ceremony also attended by thousands of police officers from across the U.S. and Canada. At both funerals, Mayor Bill de Blasio and Police Commissioner William Bratton eulogized the slain officers, who were ambushed by Ismaaiyl Brinsley, a 28-year-old with a history of arrests who made threats against police on social media after shooting his girlfriend in Baltimore on Dec. 20.

Brinsley's threats were apparently connected to recent police incidents involving the deaths of African-Americans, including the fatal shooting in August of Michael Brown, in Ferguson, Missouri, and a grand jury's decision two weeks ago not to indict a New York officer accused of placing a chokehold on a Staten Island man, Eric Garner, who died during an arrest last summer.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

Liu's death marks the first time a Chinese-American NYPD officer has been killed in the line of duty. All along the funeral procession route, which stretched from 11th Avenue to 18th Avenue, Chinese-American onlookers pressed up against metal police barricades set up along the curb, straining to take photos and video as police officers filed into formation along 65th Street. A contingent of more than 100 ethnic Asian officers, including Yang and about 20 Asian-Canadian Toronto constables, led the march toward the funeral home.

For many in the crowd, it was a proud moment.

"First and foremost, Liu is Chinese like us," Yaoxun Liu, an immigrant from Shanghai who traveled in from New Jersey along with 70 other Chinese-Americans to attend the funeral, said in Mandarin. "He was violently killed serving the community. Even though we don't know him, we came from nearby to show support."

RELATED: Chinese Community Reels After Brooklyn NYPD Shooting

Helen Cai, a Chinese immigrant living in New York, expressed a similar sentiment. She and a dozen members of a Chinese-American community group stood at the intersection of 14th Avenue and 65th Street, cradling a bouquet of flowers and holding aloft white paper plates on which were written Chinese characters. The plates, when lined up, formed a message mourning Liu's passing.

"Liu is the pride of our Chinese, even though he is also the pride of every New Yorker," Cai said in Mandarin.

The eulogies at Sunday's service gave a more complete picture of Liu's life than before, painting a portrait of the newlywed and only son as a devoted family man and a dutiful cop. He was the teenager who ended his playground basketball games early to shop for groceries for his parents. He was the man who gave up his favorite sticker of the Statute of Liberty to his 4-year-old cousin that he got when he first arrived in America. He was the officer who responded to a call of an elderly man who had fallen in his home and ended up staying longer than he had to because the Vietnam veteran needed someone who would listen.

Photos: Thousands of Officers Honor NYPD's Wenjian Liu

"But to me, he is my soulmate," said Liu's widow, Peixia Chen. "Wenjian is an incredible husband, son, co-worker and friend. My best friend. But he is much more."

Police line the streets before the funeral of Detective Wenjian Liu in Brooklyn on Sunday. Seth Wenig / AP

Many of the Asian-American police officers at Liu's funeral said being a cop is not just about enforcing the law, but about making a difference in the communities where they serve. Detective Ron Bongat, a Philippine immigrant and 15-year veteran of the Oak Park Police Department near Chicago, became a police officer for that very reason.

"I got tired of complaining about crime, so I thought I'd do something about it," he said.

In recent years, a growing number of Asian-Americans has joined the ranks of the NYPD. As of November, there were 2,144 Asian-American police officers, compared to 1,597 in January 2010, said Sgt. Carlos Nieves, a spokesman for the department. City Council member Margaret Chin, whose district includes Manhattan's Chinatown, told NBC News last month that efforts to recruit more Chinese-American officers had been very successful.

Bongat, who is one of five Asian-American officers in Oak Park's 125-member police force, hopes the deaths of Liu and Ramos can serve to build stronger ties between communities and the police officers who serve them.

"I hope there is a sense of community and support for each other," he said. "Not just for officers, but for the community as a whole."