A three-day stand-off between soldiers and militants in Indian-administered Kashmir has ended with all three attackers killed, police said.
The militants killed five soldiers and a civilian in the gun battle near Srinagar.
Clashes began when the gunmen ambushed a military convoy before taking refuge in a training institute on Saturday.
A new exchange of gunfire began on Sunday morning as soldiers repeatedly tried to dislodge them.
Part of the building was on fire as security forces came under prolonged gunfire.
Two army captains were among those killed, military officials said.
"The encounter is over. All three militants have been killed," Reuters quoted Deputy Inspector General of Police Ghulam Hassan Bhat as saying on Monday.
About 100 students and staff were evacuated from the building on Saturday as it was encircled by troops.
Earlier on Monday, the security forces said they were preparing for a final assault on the institute and were reported to be using reconnaissance drones in preparation.
Police have described the militants as "suspected anti-India rebels".
The gunmen took refuge in the government-run Entrepreneurship Development Institute after attacking paramilitary forces in a convoy on the main road linking Srinagar to Jammu.
Witnesses say the gunmen told civilians in the complex to "save themselves" and move to a nearby hostel on the campus as they broke into the premises.
Kashmir, claimed by both India and Pakistan in its entirety, has been a flashpoint for more than 60 years.
The two South Asian rivals have fought two wars over the region in the Himalayas.