Security forces launched an anti-militancy operation in the wee hours in Hadoora area of Ganderbal district, 25 km from here, following information about presence of militants in the area, an army official said.
He said as the security forces were closing in on the position of the militants, the latter opened fire on the troops who retaliated.
"In the ensuing gunbattle, two militants were killed," he said, adding they were identified as Abu Anas and Abu Ali, both foreigners associated with the Lashkar outfit.
The official said two AK assault rifles, ammunition and hand grenade were recovered from the possession of the slain militants.
"It (killing of militants) is a good success for the security forces especially as it comes ahead of the January 26 (Republic Day)," he said.
This is the second major encounter in Kashmir this year.
Earlier on January 16, security forces killed three local militants in an encounter in Pahalgam area of south Kashmir.
A police spokesman said the slain duo were active in Srinagar-Ganderbal area for the past three years and had been recently directed by their mentors in Pakistan to carry out attacks on security forces and civilians on the eve of Republic Day.
"These slain militants were transporting newly infiltrated groups from one place to another and were managing safe places and hideouts for them," the spokesman said.
"They were recently directed by mentors in Pakistan to carry out attack on security forces/civilians on the eve of forthcoming Republic Day celebration 2017 in district Ganderbal and Srinagar," he added.
Giving further details, the spokesman, "They (slain militants) were operating in District Srinagar and Ganderbal areas since January 22,2013 and had recently started coordinating with Hizbul Mujhaideen."
They were involved in the killing of a civilian Abdul Ahad Dar in Gusoo area of Zakoora on May 5, 2015.
"They were involved in Fidayeen attack on August 15, 2016 at Nowhatta in which a commandant of CRPF Pramod Kumar and a police constable of J&K police Rouf Ahmad were martyred.
"They were also involved in the attack on SSB convoy at Zakoora Srinagar on October 14, 2016 in which one SSB Jawan was martyred and seven SSB personnel and a police constable were injured," he added.