The encounter ended as the two militants hiding in the house escaped. The security forces have launched a combing operation to hunt the militants.
Police said troops of 22 Rashtriya Rifles and the Special Operations Group of the state police surrounded a house in Sopore, 52 km from here, on Saturday evening following a tip-off on the presence of militants.
"The militants started indiscriminate automatic gunfire at the surrounding security men.
The house has been completely marked off to ensure the militants are unable to escape under the cover of darkness in the area," a senior police officer said.
Reports reaching here said a top commander of Harkat-ul-Mujahideen guerrilla outfit is inside the house.
Sopore town was recently upgraded to the level of a police district following an upsurge in guerrilla activities.