The encounter lasted four hours, Jammu and Kashmir Director General of Police Kuldeep Khoda said.
The militants, identified as Altaf and Zahoor, were involved in a car bomb blast and killing of two policemen in Pampore last year, he said.
Two AK rifles were recovered from the militants, SP Avantipura Basheer Khan said.
Acting on specific information, police and army launched a combing operation in village Andrusa where the militants were hiding.
When the militants opened fire at them, the security forces retaliated in which the two terrorists were killed.