The militants, who sneaked into Upper Dir district from Afghanistan on Wednesday, destroyed eight schools as skirmishes between the rebels and security forces continued for the third day on Friday.
The Taliban fighters had initially attacked a check post at Shalotal, triggering fierce gun battles that killed 28 security personnel and six civilians.
Officials said an estimated 45 militants too were killed in the fighting. The militants are now in Bin Shahi area near the border.
Additional troops backed by gunship helicopters were deployed in the area. The troops used mortars and heavy weaponry to target militant positions.
Shalotal area has been cleared of militants, officials said. The Afghan ambassador was summoned to the Pakistan foreign office on Thursday and Foreign Secretary Salman Bashir conveyed Islamabad's "strong concern on the cross-border attack launched from the territory of Afghanistan in Dir by some 300-400 militants".
Bashir demanded "stern action" by the Afghan army and United States and NATO forces against the militants and their hideouts in Afghanistan.
Khyber-Pakhtunkhwa Senior Minister Bashir Ahmed Bilour on Friday strongly denounced the attack by the Afghan militants.
Describing such attacks as "intolerable" and a matter of great concern, he said NATO forces should take notice of the incident and stop them.
NATO forces should make their surveillance on the other side of the border more effective to check the movement of militants into Pakistan, Bilour said.
Image: A soldier stands guard at the site of clashes between militants and security forces in Upper Dir, along Pakistan's border with Afghanistan, on Friday
Photograph: Reuters
Pak President slams army for terror links
Cong, AIUDF to battle it out in Dhubri
Siachen talks fruitful, but need more time: Antony
Nato strike kills Gaddafi's son, 3 grandchildren
Obama falters in Af-Pak: Where's India's response?