Former Mayor Ed Koch took to his grave the belief that Andrew Cuomo was behind the scurrilous posters that appeared in Queens during the 1977 mayoral race between Koch and Mario Cuomo. “Vote for Cuomo, not the homo,” the posters said in a gay-baiting bid just days before voters went to the polls.

That wasn’t all. In “I, Koch,” a 1985 unauthorized biography of Koch, my co-authors and I reported that Mario Cuomo’s campaign “hired a private detective to try to find out who Koch’s ‘boyfriend’ was and attempted to plant stories with the press that Koch was gay.”

Cuomo’s campaign also offered money to a Catholic group in Greenwich Village if it would “publish a newsletter suggesting that Koch was gay.” The group refused.

And Mario Cuomo himself publicly suggested that Koch supported the right of gays to “proselytize.”

Several days after his victory, Koch was still angry over the desperate 11th-hour efforts, telling an interviewer that Mario Cuomo was surrounded by “lowlifes.” In later years, Koch forgave both Cuomos, but he never, ever forgot.

“History,” Mark Twain reportedly said, “doesn’t repeat itself, but it often rhymes.” And so, 41 years later, the media and political class are talking about a new dirty trick that has Andrew Cuomo’s fingerprints all over it.

The recent mailer from the state Democratic Party, which Cuomo funds and controls, isn’t subtle. It says, without evidence, that his primary opponent, Cynthia Nixon, can’t be trusted to support Israel and Jewish causes or to fight anti-Semitism. It was sent to about 7,000 homes in ultra-Orthodox neighborhoods.

“With anti-Semitism and bigotry on the rise, we can’t take a chance with inexperienced Cynthia Nixon,” the mailer reads. It says she is “against funding yeshivas, supports BDS, the racist, xenophobic campaign to boycott Israel” and is “silent on the rise of anti-Semitism.”

Cuomo, by contrast, is said to be strong on all the key issues. The flier credits him with “providing over $200 million to support yeshivas.”

Some things change — Cuomo has not made an issue of Nixon being a lesbian. And some things don’t. Just as he claimed innocence and ignorance in the Koch race, Cuomo claims he knew nothing — nothing! — about the Nixon mailer.

That was impossible to believe even before The Post’s report that Cuomo’s campaign contacted the paper before the mailer became public. In an email, a campaign aide urged a reporter to look into Nixon’s relationship with the BDS movement.

If that isn’t a one-two coordinated punch, what is it?

Cuomo’s willingness to play dirty has been obvious for years, but the attack on Nixon is roiling the final days of the primary as if there is a sudden discovery of a hidden flaw in his character.

I find the reaction peculiar, and ascribe much of it to the identity crisis playing out at the New York Times editorial page.

The Times, somewhat to my surprise, endorsed Cuomo over Nixon. Probably sensing that Nixon had no chance to win, the editorial was a nose-holding affair where the paper offered only backhanded compliments to the man it was urging voters to back.

It wrote that Cuomo had “significant accomplishments,” but had done “little to combat the corruption in the Legislature and his own administration, and he has allowed the subway system, the foundation of the New York City economy, to rot.”

It also endorsed outsiders who are critical of Cuomo, including Zephyr Teachout for attorney general and Jumaane Williams for lieutenant governor, saying they need to hold his feet to the fire.

All that was strange enough, and then came the Nixon attack. By Tuesday, the Times was showing clear signs of buyer’s remorse.

A new editorial called the Nixon mailer “a smear” and demanded Cuomo “personally apologize and condemn those outrageous attacks.”

Strong stuff, but also strange stuff. I sense the Times is more embarrassed for itself than it is outraged by Cuomo’s conduct.

The paper took heat from progressives for endorsing Cuomo and is now fighting for credibility among them by attacking him. But if it really cared about what it calls “dirty politics in New York,” it never would have endorsed him in the first place.

Consider the long history of the governor’s vile attacks on New Yorkers who disagree with him. He routinely denounces “ultra conservatives” and has said: “Right to life, pro-assault weapons, anti-gay — if that’s who they are, they have no place in the state of New York.”

After President Trump’s victory, Cuomo was reluctant to attack him by name. But with Nixon pushing him to the left and national Dems going crazy over Trump, Cuomo sensed the changing wind and joined the mob, hurling overheated charges without end.

He declared that America “was never that great” and called Immigration and Customs Enforcement agents a “bunch of thugs.”

On those and similar occasions, the Times editorial page was silent. It never found fault with anything Cuomo said — as long as he was attacking Republicans.

Indeed, the paper’s editorials echo those attacks: They too are viciously anti-conservative, viciously anti-Trump and against reasonable enforcement of immigration laws. But now that their favorite son is turning his blowtorch on another Democrat, the paper is suddenly outraged.

Oh, please. They deserve each other.

9/11 lesson unchanged

Seventeen years and counting. With each passing anniversary, it becomes more difficult to find anything new to say about 9/11.

With good reason. The story is not about what’s new, although it is always worth knowing the latest about the terrorists still being held captive. And we can find some delight, though tinged by sadness, in the stories about the adults who were children then and lost a parent on that awful day, yet persevered.

But the essential meaning of 9/11 never changes and doesn’t need an update. It was the day when terrorism crossed the globe to slay the innocent in the heart of our city and nation.

The world changed that day, and it has stayed changed. There is no going back. That is what the living must never forget.

At last, NYCHA’s mea dumpa

The hits keep coming for the city’s Housing Authority. A federal report ranks three Upper East Side projects in Manhattan among the most troubled in the nation.

The problems run the gamut from faulty elevators and broken boilers to leaky roofs and mold.

Usually, the agency, which is under Mayor Bill de Blasio, would blame others. But this time, a spokeswoman admitted the problems without pointing fingers.

The findings, she said, illustrate “the work ahead for our new leadership team.”

Here’s hoping that attitude marks a new start. After all, you can’t fix a problem until you admit it.

To Dems’ dismay

Good news for Americans could be bad news for Democrats. Here are three headlines on the Drudge Report:

Small-business optimism highest ever; Tops Reagan . . .

PEW: Middle Class Income Rises . . .

Job openings climb to record 6.9 million . . .

How do you run against that?