The militants attacked an outpost of forces in Datta Khel area of North Waziristan, where forces launched an operation last year.
A security official said that security forces responded to the attack, leading to an intense gun battle.
"Five militants were killed as the attack was repulsed," he said.
Pakistani forces have cleared most of North Waziristan but some of the areas near the border are still infested with militants who occasionally launch attacks on the security forces.