Fierce fighting went on for 16 hours between troops and the militants
Three suspected militants have been shot dead and six hostages freed in the Jammu area of Indian-administered Kashmir, security forces said.
They said two women and four children were rescued, but the militants had killed three male hostages.
Troops had surrounded a house in the province's winter capital Jammu where the two sides exchanged heavy gunfire.
Officials said the rebels had slipped into India across the border from Pakistan on Tuesday.
"The operation is over. Our special forces killed the third militant early on Thursday," army spokesman Lte Col SD Goswami was quoted by the Press Trust of India as saying.
"The final assault was launched at 2345 (1815 GMT) on Wednesday by the army and the entire family of the house owner, including four children, were rescued," he said.
Earlier, a man claiming to be one of the three militants in the house spoke by telephone to the BBC's Binoo Joshi in Jammu.
The man identified himself as Talagira and said the rebels were protesting against the "atrocities committed on Muslims in Kashmir", our correspondent says.
The Hindu-majority areas around the city of Jammu have been the scene of violent demonstrations in recent months.
The Indian authorities are struggling to halt the protests, which were sparked by a dispute between Hindus and Muslims over whether land should be given to a major Hindu shrine in the Muslim-majority Kashmir valley.
Trouble began in June when the state government granted a small piece of land to a trust running the Amarnath Hindu shrine.
Muslims launched violent protests, saying the allocation of land was aimed at altering the demographic balance in the area.
The state government said the shrine board needed the land to erect huts and toilets for visiting pilgrims.
But following days of protests, the government rescinded the order, prompting Hindu groups to mount violent protests of their own.