BARAMULLA, Kashmir — At least two people suspected of being militants and one soldier were killed in a protracted gun battle in a forested area near the disputed border with Pakistan in the Indian state of Jammu and Kashmir, an Indian Army official said Saturday.

The gunmen were attempting to sneak into Indian territory from Pakistan, when they were discovered by soldiers early Friday, an army spokesman, Lt. Col. N. N. Joshi, said Saturday from Baramulla, a town near the scene of the battle.

One soldier was among those killed in the gun battle, according to an army statement on Saturday. Colonel Joshi said that the bodies of the two suspected militants were recovered along with three AK-47 rifles. “Throughout the night we heard heavy shelling in the forest,” Zahir Ahmad, a laborer who had fled a village near the fighting to Baramulla, said on Saturday. “We were scared and as soon as the dawn broke, we abandoned our home and came here.”

Both India and Pakistan claim the disputed area of Kashmir, which has been scarred by two decades of armed insurgency.