SRINAGAR, India — The Indian army said a three-day standoff with suspected rebels ended Wednesday after government forces killed two militants inside a building in the Indian-controlled portion of Kashmir. The building was extensively damaged in the fighting.

Maj. Gen. 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 injured in the initial fighting.

On Monday, militants positioned themselves inside the building in a 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 counterinsurgency police surrounded the building while firing rockets, flame throwers and grenades. The militants fired automatic weapons and grenades.

During the standoff, scores of nearby residents gathered in the streets and chanted slogans against Indian rule in a show of solidarity with the militants. They ignored government orders to stay away from the area.

In February, five soldiers, three militants 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 paralyzed daily life.

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 favor 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.