The Indian army said a three-day standoff with suspected rebels ended on Wednesday after security forces killed two attackers inside a government building in the Indian-controlled portion of Kashmir.
Major-General Ashok Narula called the operation "tricky" and said the fighting was protracted because "the building was huge and we didn't want collateral damage".
A soldier and a police official were wounded in the initial fighting.
"Two people have been eliminated and two weapons have also been recovered," Narula told reporters at the scene after the operation was declared over.
On Monday, assailants positioned themselves inside the sprawling government compound near saffron-rich Pampore town on the outskirts of the disputed Himalayan region's main city of Srinagar.
Army special forces, paramilitary soldiers, and counter-insurgency police surrounded the building while firing rockets, flame-throwers and grenades.
The fighters fired automatic weapons and grenades. The building was extensively damaged in the battle.
During the standoff, scores of nearby residents gathered in the streets and chanted slogans against Indian rule in a show of solidarity with the gunmen, ignoring government orders to stay away from the area.
In February, five soldiers, three attackers, and a civilian were killed during a three-day standoff in the same compound.
Kashmir is experiencing its largest protests against Indian rule in recent years, sparked by the killing in July of a popular rebel commander by Indian soldiers.
The protests, and a sweeping military crackdown, have nearly paralysed daily life.
READ MORE: The doctors treating Kashmiris blinded by pellets
More than 80 civilians have been killed and thousands injured, with hundreds among them blinded and maimed, mostly by government forces firing bullets and shotgun pellets at rock-throwing protesters. Two policemen have also been killed and hundreds of government forces have been injured.
India and Pakistan each administer part of Kashmir, but both claim the Himalayan territory in its entirety. Most people in the Indian-controlled portion favour independence or a merger with Pakistan.
Rebel groups have been fighting against Indian rule since 1989. More than 68,000 people have been killed in the armed uprising and ensuing Indian military crackdown.