Troops of 29 Rashtriya Rifles and police cordoned off village Goshbug in Pattan area, 30 km from here, following information about presence of militants there, a defence spokesman said.
He said the security forces came under firing from militants when troops surrounded a building where they were hiding.
The security forces returned the firing, triggering a fierce gun battle, the spokesman said adding the operation was in progress till late in the night.
A police spokesman said two militants were killed and they were yet to be identified.