A Pakistani military spokesman said that his soldiers exchanged fire with "unknown miscreants" along the the so-called Line of Control which separates Indian and Pakistani forces.
"Two of our soldiers embraced martyrdom at the spot and tw others injured later died at hospital," Major-General Athar Abbas, Pakistani military spokesman, said on Thursday.
He said that the Pakistani patrol came under attack from a wooded area along the frontier near the village of Battal.
Abbas said the soldiers returned fire and afterwards search parties were sent to hunt the attackers.
"The fire was not from the Indian bunkers," he said.
Infiltration
Lieutenant Colonel Shantanu Dass Goswami, an Indian army spokesman, said Indian and Pakistani troops both fired at the attackers, who he said were attempting to infiltrate the Indian side from Pakistan.
The fighting lasted about five hours, he said.
"There was an information sharing from both the sides to zero in on the militants," Goswami said.
Last week, India said that armed men ambushed an army vehicle and killed five soldiers on its side of the frontier.
Control of the Himalayan region is split between India and Pakistan, which both claim the whole region, and have fought two of their three wars over it.
However, violence between the nuclear-armed neighbours has declined since they launched a peace process in 2004.
Separatist fighters have been battling Indian rule in Indian-controlled Kashmir since 1989 and they reportedly slip across the frontier from Pakistani Kashmir into Indian Kashmir to battle Indian troops.
New Delhi has accused Pakistan of training and arming the separatists, a charge that Islamabad has denied.
Indian and Pakistani officials are due to meet in Islamabad next week to try to boost cooperation against terrorism as part of their peace process.