The encounter took place at village Malikpora in Vilgam area of Handwara, 85 kms from Srinagar, when Army and police launched a joint search operation following information about presence of militants there, a senior police officer said.
He said the hiding militants opened fire on the security forces, who retaliated, triggering off a fierce gunbattle which lasted several hours.
Two militants, believed to be foreigners, were killed and an army officer identified as Major Sandeep Kotwal was injured in the gunbattle.
Some arms and ammunition were recovered from the possession of the slain militants.
Earlier in the day, security forces had cordoned off a house in Malikpora village in Vilgam area of Handwar, following information about presence of militants there.
(With PTI inputs)