This is the second time in less than three weeks that civilians targeted security forces at an encounter site, the police said, worried that protests at encounter sites were becoming a pattern.
Sources said 15 people including eight security personnel were also injured in the stone-throwing incident.
The security forces had launched a search operation for terrorists in Chadoora area of Budgam district early on Tuesday morning. Cornered, the terrorists fired at the security personnel and the encounter started, police sources said. Sometime later, the villagers also gathered and started throwing stones at them.
The security personnel reportedly tried tear gas shells and pellet guns to disperse the crowd. Some shots were also fired later as the crowd showed no signs of thinning out, police said. "Doctors said one man died of bullet injuries and another died after he was hit by a tear-gas shell," senior police officer Javed Gilani told news agency AFP.
Earlier this month, a 15-year-old was killed in Kashmir's Pulwama district when security forces had to fire at villagers trying to distract them from an encounter that later led to the killing of two terrorists.
Army Chief Bipin Rawat had last month warned people against trying to help terrorists by throwing stones at the forces during an operation by, declaring that they would be treated as anti-nationals and dealt with sternly. At the army's request, the state administration had declared that prohibitory orders would kick in within a three km radius of every encounter site involving terrorists.
The Army Chief's February message came after three jawans lost their lives in an operation in north Kashmir's Bandipora area when soldiers moving towards a house where terrorists were holed up, faced a stone-throwing that alerted the terrorists.