India is getting revenge for Nannygate.

The NYPD is trying to bring home a Harlem cop who’s being detained on trumped-up charges by Indian authorities still bitter over the way their diplomat was treated in New York last year, law-enforcement sources told The Post.

“You guys like to strip-search our diplomats,” a cop at New Delhi’s Indira Gandhi International Airport told Officer Manny Encarnacion as he arrested him on March 10 for inadvertently traveling there with three bullets in his checked luggage.

Encarnacion was charged with violating the country’s Arms Act of 1959 — and is facing up to seven years in an Indian prison. He is forbidden from leaving the country until his case plays out in court.

Indian authorities are still bitter over December’s Manhattan arrest and strip search of New Delhi’s then-deputy consul-general Devyani Khobragade, who was arrested for alleged visa fraud involving her nanny.

The bust sparked outrage across India because of the way Khobragade was handled and allegedly denied diplomatic immunity.

The NYPD is facing an uphill battle trying to help Encarnacion, trying for weeks to get the well-liked detective candidate and ex-Marine cleared. They sent a letter to Indian officials explaining the innocent mistake.

Just two days before his trip to India to visit his wife, Vida, Encarnacion, 49, was at an NYPD firing range taking his required recertification, sources said.

Encarnacion, who is assigned to the 25th Precinct, tucked three spare rounds into his jacket pocket, and forgot about them.

The bullets were still in the pocket when he packed his jacket in his suitcase.

“He knows he didn’t do anything wrong,” said Raul Borbon, 45, who is a friend of the officer. “It’s an innocent mistake.”

The newlyweds had decided to meet in India because it was easy for both to travel there. Vida is a student who lives in Iran.

Encarnacion has a local lawyer, and has been in regular touch with his superiors, Borbon said.

“His bosses already said when he comes back, they’re taking him out for Indian food — he’s already sick of the food,” the pal joked grimly.

“He was supposed to be going for 2¹/₂ weeks, but it’s turning into five weeks, if he comes back on April 19,” his next court date in India.

Encarnacion has been spending his forced Indian “vacation” with Vida, Borbon said.

“He’s out on [$1,000] bail,” said the pal, who is dog-sitting for Encarnacion’s two pets. “He’s not sweating it that much because at least he gets to spend time with his wife.”

He added, “It’s crazy. The NYPD told him, if he gets convicted of a felony, he’ll lose his job.”

Meanwhile, Encarnacion’s Facebook page has been filling up with comments from well-wishers.

“Praying for your safe and speedy return to the U.S.,” wrote one friend.