SRINAGAR, Kashmir — A high-ranking police officer has been beaten to death in Kashmir by an angry mob that witnesses say had taken him for a spy or assassin. At least two suspects have been arrested.

The victim, Mohammed Ayub Pandith, the deputy superintendent for the security wing of the Jammu and Kashmir state police, had gone to a mosque in Srinagar, the Jamia Masjid, on Thursday for prayers on Shab-e-Qadr, a night on the Muslim calendar when the Quran is believed to have been revealed to the Prophet Muhammad. A prominent religious leader and separatist, Mirwaiz Umar Farooq, was giving a sermon.

Accounts about what transpired vary. Shesh Paul Vaid, the top Indian police officer in the region, said that Officer Pandith, who had been in civilian clothes, had gone to the mosque “to ensure the protection of people offering prayers there.”

Having sent his security detail home, Officer Pandith began to feel threatened when worshipers at the mosque singled him out and began closing in, Mr. Vaid said. At a certain point, Officer Pandith pulled out his revolver “and in self-defense he fired a couple of rounds” into the crowd, he added.