The Pakistani military said it killed 29 Taliban fighters on Wednesday in the final stage of an operation aimed at forcing hundreds of insurgents back across the border into Afghanistan.
Soldiers used artillery, helicopter gunships and fighter jets against the insurgents, accused of beheading 17 Pakistani soldiers in June.
The battle was the culmination of weeks of operations in the remote valleys of the Batwar area of Bajaur tribal agency near the border.
It highlighted once again the difficulty of preventing insurgents from crossing the border to launch attacks or flee from Pakistani or NATO forces bolstering the Afghan government.
Around 400 militants had crossed from Afghanistan into Pakistan on August 23 and attacked villages, said a senior security official based in Khar, the main town of Bajaur.
The army launched operations that killed around 120 militants, another security official said from the border town of Peshawar. Twenty-five soldiers also died in the fighting.
"The militants escaped to their sanctuaries in Afghanistan and even left the bodies of their slain fighters," said the Peshawar-based official.
He said the armed forces were now establishing posts along that section of the Afghan border to thwart future incursions.
A spokesman for the militants confirmed the attacks were staged by fighters from several regions.
Pakistan and the United States, which has by far the largest foreign contingent in Afghanistan, have accused each other of failing to secure the border.
Some U.S. officials say Pakistan deliberately lets some insurgents through, a suggestion Pakistan strongly rejects.
Joint efforts to secure the long and mountainous border were hampered by a NATO strike against a Pakistani base last November that killed 24 Pakistani soldiers and severely damaged relations between Pakistan and the United States for several months.
A bomb in Peshawar killed at least 10 people and wounded more than 30 on Wednesday, police said. The bomb seemed to be targeting a van carrying officials from the Pakistan Air Force, said local police official, Imtiaz Ahmad.