The rebels sneaked into the base near the town of Uri before lobbing grenades and opening fire with automatic rifles on the fleeing soldiers, an army officer told AFP on condition of anonymity.
Tents and other temporary shelters for the hundreds of soldiers stationed at the base near the de facto border with Pakistan caught fire in the raid, the army and the senior officer said.
Indian Prime Minister Narendra Modi vowed to punish those behind the “cowardly” and “despicable” attack that also left four militants dead and scores of soldiers injured.
No one has claimed responsibility, but India regularly accuses rebels based in Pakistan of moving across the heavily militarised border known as the Line of Control (LoC) to launch attacks on its forces.
“We strongly condemn the cowardly terror attack in Uri. I assure the nation that those behind this despicable attack will not go unpunished,” Modi said in a series of tweets.
The encounter resulted in “heavy casualties. We salute the sacrifice of 17 soldiers who were martyred in the operation,” the army said in a statement.
The raid which started just before dawn was the worst such attack for many years in the territory, where an armed rebellion against Indian rule erupted in 1989.
Rebels stormed an army camp in the Uri area in December 2014, killing 11 soldiers and police officers.
Soldiers are now searching the base, 100 kilometres (62 miles) west of the region’s main city of Srinagar, for any more militants, the statement said.
Twenty-eight injured soldiers have been airlifted to a military hospital in Srinagar, four of them in a critical condition, according to an army officer. Large numbers of soldiers are stationed at Uri after finishing their tour of duty in the disputed Muslim-majority region.
Indian Kashmir in the grip of deadly unrest that has lasted for more than two months. Protesting residents are clashing almost daily with security forces in the worst such violence since 2010.
At least 87 civilians have been killed and thousands injured in the protests against Indian rule, sparked by the killing of a popular rebel leader in a gunbattle with soldiers on July 8.