Army personnel detected some movement in the sector in north Kashmir's Kupwara district on Saturday night. When the intruders were challenged by the army patrol, they opened fire, said army spokesman Naresh Vij.
He said three militants were killed in the gunbattle, while the army suffered no casualties.
The spokesman said three to four militants managed to escape.
The infiltration bid followed three ceasefire violations that took place in the sector since last Friday. A Brigadier and two soldiers were wounded when Pakistani troops opened fire on Indian posts.
Pakistani troops violate ceasefire again
J&K: Officer killed as army foils infiltration bid
How Indian media helped defuse crisis with China
Four policemen killed in ambush by militants in Kashmir
Lashkar terrorist killed in Srinagar encounter