PESHAWAR - 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.

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. 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.

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 US officials say Pakistan deliberately lets some insurgents through, a suggestion Pakistan strongly rejects and accuses Afghan and ISAF of allowing sanctuaries of the militants in bordering Afghan provinces of Nuristan and Kunar who then launch attacks on Pakistani areas from there.

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.