A police spokesman said the encounter took place after the militants entered a building.
Pramod Kumar, commandant of the 49th Battalion of the Central Reserve Police Force (CRPF) lost his life in the operation.
Eight other CRPF personnel, were also injured in the attack.The spokesman said the identity of the slain militants is being ascertained.
The operation lasted for around six hours.
Home Minister Rajnath Singh has expressed deep pain over the death of a CRPF Commandant Pramod Kumar in attack by militants in Jammu and Kashmir .
Saluting the officer for his valour and supreme sacrifice, the Home Minister said Pramod Kumar served the nation till his last breath.