The security forces chased the militants and engaged them in nearby fields, police said adding both the militants were killed after a brief encounter.
Security forces also recovered the rifle of one of the slain cops which the militants had taken away after the attack, the police said.
Shohda (martyrs') Brigade, believed to be shadow outfit of Lashkar-e-Toiba, claimed responsibility for the attack.
This is the first militant attack on any election-related activity in Kashmir since the schedule for Lok Sabha polls was announced by the Election Commission last month.