Protesters torched a police armoured vehicle as masked militants fired automatic rifles into the air in honour of the dead men, a police officer at the scene told AFP on condition of anonymity.
The gun battle broke out early Thursday morning in Shopian, 45 kilometres (28 miles) south of the main city of Srinagar.
Indian army kills two ‘rebels’ in Kashmir
"The militants fired on a patrol party. In retaliation both were eliminated," army spokesperson, Colonel N N Joshi told AFP.
The two militants were members of Hizbul Mujahideen, the largest local rebel group operating in Kashmir.
After the shootout, thousands of angry villagers came out onto the streets, throwing stones at police and chanting slogans in support of the rebels.
Police fired tear gas at the protesters but later withdrew to avoid an escalation.
Army kills two suspected separatists in Indian Kashmir
Authorities in Kashmir say there has been a rise in violent protests over the deaths of local militants in the restive Himalayan region, which is divided between India and Pakistan but claimed in full by both.
Local police and the army have issued public warnings asking residents within a two-kilometre (1.25-mile) radius of a gun battle to stay indoors, but the request is usually ignored.
Hizbul Mujahideen is one of several rebel groups fighting an estimated half a million Indian forces deployed in the restive region, seeking independence or a merger with Pakistan.
Tens of thousands have died in the fighting, mostly civilians, since the insurgency broke out in 1989.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ