The city’s narcotics cops are being told to stop arresting suspects over the age of 40 — a major strategy shift designed to target younger dealers, who are more likely to carry guns and use them, The Post has learned.

Top brass issued a directive that makes it all but impossible for cops to bust older drug suspects, in order to combat a spike in shootings — which are up 7 percent in 2015 compared with the same period last year and 12 percent over the last four weeks, police sources said.

The new policy was laid out in a May 14 memo obtained by The Post that scolded police bosses for busting people outside the 18-40 demographic — and demanded written explanations for arrests of midlife perps.

Division commanders who got that memo immediately ordered the rank and file to stop making collars in that age group and threatened officers with transfers and other discipline if they did not comply, according to multiple police sources.

The memo was signed by Assistant Chief Brian McCarthy, head of the Narcotics Division, who admitted at a meeting last week the directive came from higher up, said a source who was in attendance.

“A previous topic of discussion has been the need to target violent offenders who are 18 to 40 years of age. It has been well established that the individuals in this age demographic are responsible for the majority of violent crime,” McCarthy wrote. But, he added, a review of arrest records made by narcotics cops “revealed a lack of commitment to this effort.”

As a result, commanders will have to file weekly reports to McCarthy listing every arrest of a person over 40, and supervisors in the field will have to immediately notify their captain and get permission to bust any drug suspect that age.

Commanding officers vented about the directive at a Friday meeting with McCarthy at One Police Plaza, according to sources.

“You’re telling us not to lock these people up,” one of the officers said. “However, the people over 40, they could be your burglars, they could be responsible for car break-ins, they could be responsible for robberies.”

McCarthy allegedly responded, “I’m glad you brought that up, but [the bosses] don’t give a s–t.”

A police source said, “This came from above him. It’s amazing, but if you’re over 40, go out and start selling drugs because you get a freebie.”

Narcotics cops have been scolded by their superiors for arresting older dealers, sources said. And a group of cops from The Bronx were even mocked about it at a recent CompStat meeting as they laid out photos of some recent arrests of perps who all appeared to be 40 or older.

“You should have brought those people to Lourdes instead of Central Booking,” an angry chief cracked, referring to the French town with a spring that Catholics believe has healing powers, a law enforcement source said.

A veteran source told The Post that a respected sergeant was threatened by the precinct’s commanding officer, Inspector Charles McEvoy, with a transfer after his team busted four older suspects.

“They were all over 40 years old. They were put through the system and went down to The Tombs. And [the sergeant] was pulled into a room. He was told if he does it again, he and his team will be launched out of Manhattan North. He’s doing what he’s supposed to do. That’s his job,” the source said.

“I’m blindsided by this. I don’t even know what to say. We’re letting criminals go. Crime is going to skyrocket.”

Sources said the rule makes it impossible for undercover cops to do their jobs.

“If the undercovers are out there and they are trying to buy from drug dealers, they have to have a conversation with them and find out how old they are. And if they’re over 40, they have to pass and move on,” the detective said.

NYPD spokesman Stephen Davis said that after “an analysis of the violence, we identified the core group of people committing the violence in certain areas was in the 18- to 35-year range . . . Since a fair amount of the violence is related to drug activity, our narcotics division was told to focus their efforts on those core areas and core groups.”

Davis insisted that cops “were never instructed to disregard crimes being committed by people of a certain age. No one was told that if you see someone committing a crime, and he happens to be 42 years old, that he gets a pass. That’s not the case.”

There have been 438 shooting victims this year compared to last, an 8.7 percent rise. Over the last 28 days, 126 people were shot compared to 101 for the same period in 2014, a 25 percent spike.

There have also been 378 shootings year to date, compared to 353 a year ago, a 7 percent rise. And over the past 28 days, there have been 102 shootings compared to 91 in 2014, a 12 percent rise.

Additional reporting by Philip Messing and Bob Fredericks