The militants attacked a Pakistani military post in the Datta Khel area of the district of North Waziristan, a former militant stronghold near the border with Afghanistan.
Militants have targeted a Pakistani military post in the northwestern tribal belt near the Afghan border, killing two soldiers in a firefight.
The Pakistani army's media wing said late on Saturday that militants attacked a post in the Datta Khel area of the district of North Waziristan in Khyber Pakhtunkhwa province.
No group immediately claimed responsibility for the attack.
Two soldiers were killed during the intense exchange of gunfire in the former militant stronghold, the military said.
A search of the area is being carried out to find the militants.
The military gave no indication of the identity of the attackers.
A militant stronghold
North Waziristan for years served as a safe haven for militants until the military carried out massive operations to try to clear the area.
The operations forced militants either to escape across the border into Afghanistan or hide in other mountainous areas near the border.
Still, militants often strike against security forces.
Pakistan is holding talks with militants known as the Pakistani Taliban with the help of the Taliban government in Afghanistan.
There is a temporary cease-fire in place.