Soldiers and special operations officers cordoned off Panzgam village, about 35 kilometres (22 miles) south of the main city of Srinagar, before dawn after receiving a tip off that militants were hiding inside a house.
“The operation started in the night in which three terrorists were killed,” Colonel N. N. Joshi, an army spokesman, told AFP.
As word of the killings spread, hundreds of villagers came out onto the streets, throwing stones at police who fired tear gas to disperse the crowd, an officer said on condition of anonymity.
Police later identified the deceased as members of Hizbul Mujahideen, a local rebel group opposed to Indian rule of Kashmir.
Kashmir has been divided between India and Pakistan since the end of British colonial rule in 1947. Both claim the Himalayan territory in its entirety.
Hizbul Mujahideen is one of several rebel groups that have since 1989 been fighting Indian forces deployed in the disputed region, calling for independence or a merger of the region with Pakistan.
The fighting has left tens of thousands dead, mostly civilians.
Since the beginning of the year, residents have frequently taken to the streets to support rebels following gunbattles with government forces.
Two civilians have died in the resultant clashes and scores have been injured since February.
Civil and military authorities have issued repeated warnings asking people within a two kilometre-radius of a gunbattle to stay indoors, but the warnings have mostly been ignored.