By Sebastien Malo

BETHPAGE, N.Y. (Reuters) - Thousands of law enforcement officers gathered at a Long Island funeral home on Thursday to pay their respects to a New York policeman who died of a fatal gunshot wound this week, the city's fifth officer to die in the line of duty since December.

Brian Moore, a 25-year-old, second-generation police officer died on Monday, two days after he was shot in the head while sitting with his partner in a patrol car in the borough of Queens. An ex-convict is being held in the case.

A long line of officers in dress blue waited outside the home in suburban Bethpage where Moore's wake was being held, Among the family, friends, politicians and NYPD brass in attendance was New York Governor Andrew Cuomo, who paid tribute to Moore for emulating his father.

"He followed dad into the business," said Cuomo, who entered politics like his father Mario, a former New York governor. "There is a sense of love and respect that that shows from son to father that is louder than any words."

Mayor Bill de Blasio, who was presenting his budget proposal, had not arrived by Thursday afternoon.

James Carver, president of the Nassau County Patrolmen's Benevolent Association on Long Island, said he expected 30,000 officers to attend the wake, where there was little sign of the tensions that pervaded services for two patrolmen who were fatally ambushed in Brooklyn in December.

At their funerals, thousands of officers turned their backs on de Blasio as he eulogized the patrolmen, who were slain by a gunman who said he wanted to avenge black men killed by white police officers.

That display of disdain came after Patrick Lynch, the head of New York City's main police union, said the mayor had "blood on his hands" for encouraging an anti-polite climate.

By contrast, the mayor and Lynch shook hands warmly at a weekend news conference after Moore was shot. That highlights a new spirit of detente between rank-and-file police and the mayor's office, said Dennis Kenney, a professor at John Jay College of Criminal Justice and a former police officer.

"The ground has changed a little bit since the unions had their period of being upset," said Kenney. "They are in a weaker position."

Kenney said the change mirrors a gradual shift in public opinion against law enforcement following a recent spate of fatal encounters between police officers and unarmed black men, including the death of Eric Garner on New York's Staten Island last year.

"I think that the mayor has worked hard at addressing a number of serious concerns of police officers in the city," said Roy Richter, president of the Captains Endowment Association, one of the NYPD's five police unions.

The decision by grand juries to bring no charges in the Garner case and in the death of a teenager in Ferguson, Missouri, fueled a nationwide wave of protests against police violence.

More recently, six Baltimore officers were charged in the death of Freddie Gray, a African-American man who suffered a fatal injury while in custody.

Moore was shot days after Gray's death, but Police Commissioner Bill Bratton said there was no indication that the suspect in the Queens case was motivated by revenge.

Moore and his partner had been trying to question the suspect, Demetrius Blackwell, 35, who has an extensive criminal background and was wanted on a weapons charge, after they saw him seeming to adjust an object in his waistband, police said.

Police said Blackwell pulled out a gun and fired into the vehicle, striking Moore.

The weapon, which was later recovered, had been stolen in Georgia in 2011, police said.

A 33-year-old NYPD officer who declined to give his name said he appreciated de Blasio's support in the aftermath of Moore's death.

"That helps morale for us," the 10-year veteran who works in a Queens precinct said. "If there's good vibes both ways, I think it's awesome. I welcome that."

(Writing by Frank McGurty; Editing by Mohammad Zargham and Andrew Hay)