Police Commissioner Ray Kelly yesterday told the Associated Press exactly what it needed to be told: Take a long walk off a short pier.

Good for the commissioner.

No, Kelly didn’t use those precise words. Actually, he didn’t even mention the AP by name — or any other critics.

He’s too professional for that.

But his remarks at a Manhattan Institute conference on counterterrorism (excerpted on the opposite page) serve as an unmistakable — and well-warranted — rejoinder to the wire service’s recent “exposé” on post-9/11 NYPD tactics.

Kelly made no apologies for the department’s actions since the terror strikes 10 years ago Sunday. Nor should he have: They helped enormously to keep New York safe.

But the AP, in a spate of recent articles, has sought to raise fear over what it clearly thinks have been post-9/11 NYPD civil-liberties abuses.

And the cops’ longstanding critics — the Council on American-Islamic Relations and the New York Civil Liberties Union, for instance — are only too happy to take up the cause.

The department has sent undercover officers into minority neighborhoods, the AP warned. It’s monitored “bookstores, bars, cafés and nightclubs” and used “informants” in mosques. Indeed, it’s even (horrors!) kept close ties with the CIA and FBI.

Gee, sounds to us like Kelly & Co. are doing exactly what they should be doing, post-9/11. And, fortunately, they intend to keep right on doing it. Unapologetically.

After 9/11, Kelly shuffled the department to better address terror. “We could not defer this responsibility to others,” he said.

Top brass set up a formidable counter-terror unit, recruiting top-notch and diverse talent, employing a range of tactics.

It’s worked pretty well.

Now, he intends to continue to send officers “to infiltrate a terrorist cell before it has a chance to … kill New Yorkers.”

Ask “informants” to shmooze a fellow New Yorker? “Yes, if that New Yorker was someone like Ahmed Ferhani, who pledged to, ‘blow up a synagogue in Manhattan and take out the whole entire building.’ ”

Obviously, civil liberties are important.

And the NYPD must follow the law — though there’s no credible reason to believe that it hasn’t. Or that it doesn’t.

What the AP and NYCLU forget is that the world — and, critically, the law itself — changed after 9/11. New Yorkers understand that counterterror folks need to be aggressive about pre-empting attacks to protect them.

Survival comes first.

Kelly said he’ll speak today with the families of the 23 cops killed on 9/11: “I’ll tell them that the NYPD is in this fight for the long haul” and will “do everything lawfully in our power” to keep the city safe.