Thousands of NYPD cops, still seething over Mayor Bill de Blasio’s characterization of them as the bad guys, defied their commissioner and turned their backs on Hizzoner on Sunday as he eulogized the second of two officers killed by a police-hating assassin.

The bitter, silent protest by the officers stretched for blocks along 65th Street in Brooklyn as de Blasio’s image appeared on giant video screens during the service for fallen Finest Wenjian Liu at the Aievoli Funeral Home in Dyker Heights.

At one corner, a cop called out “About face!’’ and officers in range of his voice — as well as many civilians — did just that.

The blue snub of de Blasio was similar to the one at last week’s funeral for the officer killed with Liu, Rafael Ramos, and at Woodhull Hospital, after the mortally wounded cops were rushed there following the shooting Dec. 20.

Police Commissioner Bill Bratton — who called the back-turning at Ramos’ funeral “very inappropriate” — had urged cops not to repeat the move.

[theplatform account=”4uMbOC” media=”eYnhupHBeIYb” player=”Ud34RrXnH_qf”]

“I turned my back last week on [de Blasio], and I will continue to turn my back whenever I hear him speak because he disrespected me, Officer Ramos and Officer Liu when he said he warned his son, Dante, to be wary of cops,” said a uniformed cop at the funeral.

De Blasio had said after the controversial grand jury rulings in the Eric Garner and Michael Brown cases that he had to “train” his biracial son about the “dangers” posed by cops. Garner and Brown, both black, were killed in confrontations with white officers.

One cop standing with his back to de Blasio said: “I can’t stand even looking at him. He has no friends here.”

Law enforcement sources estimated the size of the crowd at 28,000, surpassing even the 23,000 who attended last week’s service for Ramos and making it the largest NYPD funeral ever.

Some of the cops closest to the funeral home didn’t move as de Blasio took the podium inside, but the overwhelming majority of those behind them turned around to protest Hizzoner.

[theplatform account=”4uMbOC” media=”lOvLDUWUslzl” player=”Ud34RrXnH_qf”]

One cop who didn’t turn his back but looked away said, “I didn’t turn my back out of respect for the commissioner. But there’s no way I’m going to look at the mayor. He’s a joke. Everything he says today, he’s doing it to cover his a- -.”

In a message read at all roll calls through Sunday, Bratton pleaded with the rank and file to be bound by “tradition, honor and decency” and not disrespect the mayor.

Patrolmen’s Benevolent Association President Patrick Lynch, who led the scores of cops who turned their backs on de Blasio at Woodhull, defended Sunday’s demonstration.

“New York City police officers have opinions, too, and we’re going through a very emotional and difficult time,” Lynch said.

“They did it respectfully, in the street, not inside the [funeral home] and not during the service.”

Among the mourners were NYPD Deputy Commissioner Larry Byrne, whose cop brother, Eddie, was murdered in 1988; Detective Steven McDonald, who was shot and paralyzed in 1986; and Detective Terrence McAllister, who was wounded when fellow cop Kevin Gillespie was murdered in 1996.

None of them took part in the de Blasio protest.

During his eulogy, de Blasio noted that while “New York has been, from its earliest days, the most tolerant of cities,” during recent weeks, “that harmony has been challenged.”

Bratton defended the NYPD against critics by noting its diversity.

“We always lose the good ones, [because] almost all of them are the good ones,” he said.

Additional reporting by C.J. Sullivan, Aaron Short, Kirstan Conley and Michael Gartland