One of the encounters broke out after security forces launched a cordon and search operation at Futlipora in Pakherpora area, 45 km from Srinagar, following information about the presence of terrorists in the area, an army official said.
He said the terrorists opened fire on security forces, who retaliated, triggering a fierce gun battle.
"Four militants were killed in the gun battle," the official, said adding the operation was still in progress.
A police official said three of the killed terrorists were foreigners while one was a local, identified as Shabir Ahmad Dar. The official said the terrorists belonged to the JeM.
In another encounter at Bomai in Sopore area of Baramulla district, security forces shot dead one terrorist, a police official said.
The terrorist has been identified as Muzamil, a resident of Pakistan, who was affiliated with Lashkar-e-Toiba (LeT), the official said, adding a cache of arms and ammunition was recovered from him.