A suspected war criminal who allegedly played a key role in the slaughter of 40,000 civilians in Sri Lanka has landed a cushy job at the United Nations — with full diplomatic immunity.

Human-rights groups are outraged that Shavendra Silva, 46, a top ex-military commander, was named Sri Lanka’s deputy permanent UN representative in August, after which he moved to New York.

His arrival came a year after his troops defied international pleas and shelled a no-fire zone packed with women, children and elderly refugees, according to observers.

Silva also stands accused of mowing down a group of separatist political leaders who agreed to surrender and were waving white flags when they were shot.

“It’s a slap in the face,” said an investigator familiar with Silva, who last year oversaw the final months of a brutal 26-year civil war against Tamil separatists on the island nation off India’s southeastern tip.

The war started in 1983 after the Tamils, a Hindu ethnic minority, were denied power by the ruling Sinhalese, Buddhists, and formed a violent resistance group, the Tamil Tigers.

“Thousands were killed or starved. There were massive human-rights violations and he’s the No. 1 suspect,” said the investigator, a human-rights group expert who asked not to be identified.

“And they send this guy here? There’s no one other than him in the mission who was involved in this.”

Silva claims 11,000 friends on Facebook. The barrel-chested former major general also maintains his own site, shavendrasilva.com, filled with photos of himself in combat garb and a list of his battlefield successes.

He works from an office at the Sri Lankan mission on Third Avenue.