The fighting broke out when rebels ambushed a paramilitary convoy on Saturday, killing two troopers before taking refuge in the building on the outskirts of the state capital Srinagar.
"All the three militants have been killed in the gunbattle. Their bodies have been recovered," the inspector general of police for the region, Javaid Gillani, told AFP.
Gunmen attack convoy in Indian-held Kashmir, two army personnel dead
Separatists, who are fighting against Indian rule over the disputed Himalayan region, allowed more than 120 people including trainees and staff to flee from the building after holing up there.
Soldiers and police surrounded it and fired mortar bombs, while the militants responded with automatic weapons and hand grenades.
On Sunday two captains and a special forces soldier were killed as the gunbattle raged.
A gardener died in the initial crossfire and 13 members of the Central Reserve Police Force were wounded.
As the battle raged, hundreds of local residents came onto the streets in support of the rebels, chanting slogans against Indian rule.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ