The latest incident is likely to further heighten tensions between India and Pakistan, whose ties hit a low point following a September attack on an Indian army camp in the disputed Kashmir region.
Follow NewsGram for interesting stories on political issues in India
The soldiers and militants were killed in a gunbattle that raged for hours after the assailants lobbed grenades and opened fire while trying to enter the Nagrota base, a major army camp that is one of the four command centers in Kashmir.
Nagrota lies about 20 kilometers from Jammu on the main highway that connects the city with Srinagar. Jammu and Srinagar are Kashmir's two main cities.
Follow NewsGram for interesting stories on Indian Diaspora
Authorities said the militants took hostages, including two women and children, when they entered the building used by families of the army officers. They said three of the seven soldiers were killed in a rescue operation.
Defense Ministry spokesman Manish Mehta said, "Early morning the encounter took place. The situation is under control."
The militants apparently managed to take positions inside the complex near an artillery unit.
No group has claimed responsibility.