Witnesses said the mob attacked Mohammad Ayub Pandith, a police officer late on Thursday after he fired his pistol when confronted by worshippers at the mosque in the main city of Srinagar who suspected him of being a government spy.

Violence between government forces and civilians has spiked in recent months in the Himalayan region, where many oppose Indian rule.

A police statement said Pandith, a deputy superintendent with the security wing of the state police, had been "attacked and beaten to death by a mob".

He "sacrificed his life in the line of duty," the statement said.

Witnesses said worshippers confronted Pandith, who was not wearing a uniform, as he took pictures with his mobile phone outside the Jamia (Grand) Mosque in Srinagar during the festival of Lailat-ul-Qadr, when Muslims hold late-night prayers.

He drew out his pistol and fired, injuring three, as his colleague fled the scene, they said.

"Some youths at that point immediately pounced on him, snatched his weapon and more people came and started beating him up," a witness said.