The NYPD is pulling detectives from homicides and other investigations to help deal with the endless barrage of anti-cop protests in the city, law-enforcement sources told The Post Monday.

The directive is crushing morale among investigators, who can’t keep up with their caseloads and who are “complaining about this amongst each other,” one source said.

“The worst part is if you’re on standby [for a protest], then you don’t know what to do. Do you start working on your cases? Maybe. But then you’ll get pulled off it at a moment’s notice to go to these protests. The whole thing blows.”

One detective who has been investigating the murder of a young victim over the summer recently obtained evidence identifying the shooter — but is now on the protest detail.

“He’s trying to coordinate his schedule with the [assistant district attorney] so they can sit down and he can lay out all the evidence to make the arrest. But that hasn’t happened yet,” a source said. “Our major concern is getting [the killer] off the streets before he shoots some innocent bystander or a baby in a stroller.”

In another homicide case, this one involving a middle-aged male slain in 2013, investigators were on the verge of a breakthrough when the probe was derailed by the demonstrations.

“We were supposed to interview a potential witness a few days ago, but the detective assigned to the case was monitoring the protests,” a source said.

“We’re now trying to reschedule a meeting with the witness who we think can identify the shooter. We still don’t have a firm time and date for this interview.”

Another investigation that’s been stymied by the protests involves a domestic assault in which a man punched out his girlfriend.

“We still haven’t been able to interview the boyfriend because the detective is involved in trying to contain these protesters,” a source said.

“It’s a real pain in the ass, and our cases are piling up and we can’t work on them.”

Police Commissioner Bill Bratton said Monday the protests — which began on Dec. 3 when a Staten Island grand jury declined to file charges in the police killing of Eric Garner — have “been a significant drain on the manpower of the city, manpower that has been pulled in from precincts around the city.”

He also said the protests “are proving very costly,” with the NYPD fielding “the equivalent of 38,700 tours of duty since Dec. 3” and spending nearly $23 million on overtime.

The NYPD generally limits cops to 10 hours of overtime a week, but one cop told The Post he’s racked up 70 hours in the past three weeks.

Mayor Bill de Blasio on Monday dismissed concerns about the mounting costs of policing the protests, telling reporters: “I would ask you to consider the alternative in a free society.

“Do we tell people they’re not allowed to raise their voices? Do we tell people they’re not allowed to march? This is the result of something organic,” he said.

De Blasio also predicted the protests would die down on their own as the result of “a natural cycle.”

Additional reporting by Kirstan Conley and Michael Gartland