Up to 24 retired NYPD cops, some already getting tax-free disability pensions, are being investigated for allegedly feigning mental illness to add Social Security benefits to their juicy incomes — even as they declared themselves sane enough to pack a pistol, The Post has learned.

The insane mixed messages have set off a corruption probe at 1 Police Plaza and prompted the feds to target the retirees, as well as their lawyers and psychiatrists, sources said.

The case began two years ago when Social Security investigators on an unrelated corruption case noticed that one lawyer represented an inordinate number of retired cops filing Social Security claims, a source said.

The cops — many of whom were already collecting three-quarter, tax-free disability pensions for on-the-job orthopedic injuries — stood to gain thousands more dollars a year in Social Security benefits if deemed to also have mental problems such as post-traumatic stress disorder, the source said.

The probers compared the list of “mentally ill” retirees with a roster of ex-cops who were issued gun permits, a process in which a person has to swear he isn’t taking any drugs for mental problems.

The comparison yielded between 12 and 24 hits of names on both lists, a source said.

Retired cops often seek to keep weapons permits so they can pick up extra money working private security.

The retired cops appear to have used only a handful of lawyers to fill out the paperwork to support their bogus Social Security claims of mental illness — and collect up to an additional $3,500 monthly on top of their disability pensions, the source said.

All of the cops also used the same group of shrinks, all of whom wrote prescriptions for medications. It was not clear whether the retired officers actually took the drugs.

The probe has already snared one former cop who was convicted on fraud-related charges, a source said. He was sentenced to prison, but details weren’t immediately available.

Additional arrests are anticipated, although no breakdown was immediately available on the number of lawyers, psychiatrists or retired cops involved.

“I’d be very surprised if there are not further arrests,” one insider said.

One retired cop belatedly realized he soon may face serious consequences for his avarice.

The ex-cop, implicated in the wide-ranging probe, called a one-time police supervisor to ask for advice.

“You’re f- -ked! You need to get a criminal-defense attorney,” the supervisor said.

They’re barred from charging more than $6,000 or 25 percent — whichever is less — of the monies awarded to a Social Security claimant, and those fees are supposed to be paid by the Social Security Administration, not the clients.

A source said one lawyer charged the retired NYPD cops far more than that to put them onto the government’s gravy train — a year’s worth of SSA benefits, paid in cash.

A source said the SSA probe is being conducted by the administration’s chief investigator, John Grasso — the brother of former First Deputy Police Commissioner George Grasso — and at least two other SSA officials.