If there is a lesson NYPD Commissioner James O’Neill should have learned in 10 months in office, it’s that he can’t count on Mayor Bill de Blasio.

Yes, the mayor has come a long way since his disastrous first year that culminated in the assassinations of Officers Wenjian Liu and Rafael Ramos in Brooklyn. And yes, he has provided funds to add 1,300 new officers and promised to equip police vehicles with bullet-proof glass — which could have prevented the assassination of Bronx Officer Miosotis Familiar, who was sitting in her RV-like command post when she was fatally shot through a window earlier this month.

But key incidents in the past 10 months have revealed that the mayor doesn’t always appear to have O’Neill’s back.

Incident No. 1 occurred just a month after O’Neill was sworn in, after the fatal police shooting of Dorothy Danner, an emotionally disturbed black woman in the Bronx. Before the NYPD’s probe was completed, O’Neill said: “We failed. . . . We were called to that apartment to help someone [and] we ended up killing her.”

What O’Neill didn’t count on was that a few hours later the mayor would ramp up his words to make a political statement, exacerbating anti-police sentiment and jeopardizing O’Neill’s relations with the rank-and-file.

“It’s quite clear that our officers are supposed to use deadly force only when faced with a dire situation and it is very hard for any of us to see that that standard was met here,” the mayor said. “The Commissioner made this very clear earlier this morning . . . Dorothy Danner should be alive now. Period.”

Incident No. 2 involved Puerto Rican terrorist Oscar Lopez Rivera, whose FALN group was responsible for 146 bombings between 1974 and 1983 across the country. Among other things, the bombings cost a rookie NYPD cop his eye, killed four civilians at Fraunces Tavern and caused lifelong injuries to three cops at Police Plaza on New Year’s Eve 1982.

After President Barack Obama commuted his 55-year sentence earlier this year, de Blasio tweeted: “. . . Congratulations for all who fought for this day.”

Then came the National Puerto Rican Day Parade, whose organizers decided to honor Lopez Rivera as its “hero.” The mayor supported the idea until the bitter end. Only after politicians across the state, as well as O’Neill, bailed out of the parade, did the mayor change his stance. He insisted he had privately urged parade organizers to rescind the honor.

Incident No. 3 came at Familia’s funeral. When O’Neill eulogized Familia, he implicitly criticized anti-cop narratives in black and liberal communities, and the media, which is often too quick to criticize police in confrontations with African Americans.

Then while the city grieved, the mayor winged off to the G-20 summit to pursue his progressive agenda among protesters in Hamburg, Germany.

His message to NYC: the Hamburg protesters come first; O’Neill, the NYPD and the rest of us, second.

Need any more proof?