Police in Indian-administered Kashmir say they have killed all three militants who barricaded themselves inside a mosque on Sunday.
Police say they used teargas after negotiation efforts failed
Tear gas was used to flush out the men - said to be members of a banned group - after negotiation efforts failed.
Two hostages remaining in the mosque in Palnoo, Kulgam district, were rescued. Three others had earlier escaped.
The extent of the damage to the mosque in the town - south of the summer capital Srinagar - is not yet clear.
Violence in Kashmir has decreased amid India-Pakistan peace moves. Militants are still fighting to end India's rule in the portion of Kashmir it controls.
More than 60,000 people have been killed there since 1989 when an armed insurgency began against Indian rule.
Police say the siege began after the three militants - allegedly local members of the banned Islamist Hizbul Mujahideen group - barricaded themselves in the mosque after a security search in the area.
The police launched an operation to force the men out on Monday night, saying efforts to persuade them to leave had failed.
Earlier they rescued the remaining two civilians being held by the hostages.
But there are conflicting reports about how the civilians were taken hostage in the first place.
One account suggests they were sent into the mosque by security officials to ask the militants to surrender, reports the BBC's Altaf Hussain in Srinagar.
In a similar incident in September, the police killed two militants inside a mosque in the central district of Budgam. The mosque was partially damaged in the gun battle.