A senior Pakistani army official has said a NATO cross-border air attack that killed 24 soldiers was a deliberate, blatant act of aggression, hardening Pakistan's stance on an incident that could hurt efforts to stabilise Afghanistan.

Islamabad reacted angrily to the attack, which threatens to set back peace efforts in Afghanistan, by pulling out of an international conference in Germany next week on Afghanistan's future. It stood by its decision on Wednesday despite German hopes to the contrary.

Continuing that angry tone, Major General Ishfaq Nadeem, director general of military operations, said NATO forces were alerted they were attacking Pakistani posts but helicopters kept firing. His comments were carried in local newspapers on Wednesday that characterised the attack as blatant aggression.

Detailed information of the posts was already with ISAF (International Security Assistance Force), including map references, and it was impossible that they did not know these to be our posts, The News quoted Nadeem as saying at an editors' briefing held at army headquarters on Tuesday.

NATO helicopters and fighter jets attacked two military border posts in northwest Pakistan on Saturday in the worst incident of its kind since Islamabad allied itself with Washington in 2001 in the war on militancy.

Fury over the attack is growing, with more protests across Pakistan and tough editorials in newspapers.

The helicopters appeared near the post around 15 to 20 minutes past midnight, opened fire, then left about 45 minutes later, Nadeem was quoted as saying. They reappeared at 0115 local time and attacked again for another hour, he said.

Nadeem said that, minutes before the first attack, a U.S. sergeant on duty at a communications centre in Afghanistan told a Pakistani major that NATO special forces were receiving indirect fire from a location 15 km (9 miles) from the posts.

The Pakistanis said they needed time to check and asked for coordinates. Nadeem said the unidentified sergeant called back to say your ... post has been hit. Nadeem concluded that meant NATO knew the locations of the Pakistani posts before attacking, said The News.

The army released a video to the media showing what it said were the Pakistani border posts -- rough constructions of large stones, corrugated metal and canvas in isolated positions.

Filmed from a helicopter, it also showed foxholes and what appeared to be a mortar emplacement surrounded by rocks.

REINVIGORATED MILITARY

The NATO attack shifted attention away from Pakistan's widely questioned performance against militants who cross its border to attack U.S. and other NATO forces in Afghanistan, and has given the military a chance to reassert itself.

It is definitely not Pakistan's intention to work against the rest of the world, Foreign Minister Hina Rabbani Khar told Dawn News television on Wednesday.

But the rest of the world also has to understand that if they have pushed Pakistan into this corner, violated red lines, then they have denied the basis of partnership, she said.

Islamabad's decision to boycott next week's meeting in Bonn will deprive the talks of a key player that could nudge Taliban militants into a peace process as NATO combat troops prepare to leave Afghanistan by the end of 2014.

In Berlin, foreign ministry spokesman Andreas Peschke said Pakistan had not yet formally withdrawn and that Islamabad had a big interest in the meeting being a success. Within minutes, a foreign ministry official in Islamabad told Reuters Tuesday's decision was the final word.

U.S. Secretary of State Hillary Clinton said earlier on Wednesday Pakistan's decision was regrettable but hoped to secure Islamabad's cooperation in future.

The army, which has ruled Pakistan for more than half of its history and sets security and foreign policy, faced strong criticism from both the Pakistani public and its ally, the United States, after the raid that killed Osama bin Laden.

The al Qaeda leader had apparently been living in a Pakistani garrison town for years before U.S. special forces found and killed him in a unilateral raid in May.

Pakistanis criticised the military for failing to protect their sovereignty, and angry U.S. officials wondered whether some members of military intelligence had sheltered him. Pakistan's government and military said they had no idea bin Laden was in the country.

The army seems to have regained its confidence, and won the support of the public and the government in a country where anti-American sentiment often runs high.

More than 1,000 Pakistani religious students protested in Lahore city, yelling Death to NATO and Death to America.

If NATO and America do something like this again, we are going to turn Pakistan into their graveyard, said 23-year-old university student Zahoor Ahmad.

In the financial hub Karachi, women and children were among about 2,000 protesters. The government should end all relations with the United States, said Khadija Subzwari, a mother of four. In Multan, protesters burned an effigy of U.S. President Barack Obama and an American flag.

NATO hopes an investigation it promised will defuse the crisis and that confidence-building measures can repair ties.

But the military is firmly focused on NATO, and analysts say it is likely to take advantage of the widespread anger to press its interests in any future peace talks on Afghanistan.

The army is well aware that many Pakistanis believe the war on militancy their country joined has only served U.S. interests while thousands of Pakistani soldiers have died fighting.

If the military and government are not in sync with the public opinion, they are seen as the bad guys, they are seen as the lackeys of the Americans, said Mahmud Durrani, a former national security chief and ambassador to Washington.

In the town of Dera Ismail Khan, social worker Umar Mehsud, 28, echoed the thoughts of many furious Pakistanis.

Our leaders are asleep, oblivious to the problems of the people. It is sad and worrying that we are being bombed by a country which calls us a major ally, he said.

While officials on either side of the border disagree on the circumstances of the incident, it is possible that a retaliatory attack by NATO troops took a tragic, mistaken turn in harsh terrain where differentiating friend from foe can be difficult.

Nadeem was adamant NATO had been told it was attacking Pakistani positions. They continued regardless, with impunity, The News quoted him as saying.

(Additional reporting by Qasim Nauman in ISLAMABAD, Mubasher Bukhari in LAHORE, Asim Tanveer in MULTAN, Saud Mehsud in DERA ISMAIL KHAN and Faisal Aziz in KARACHI, and Stephen Brown, Erik Kirschbaum and Sylvia Westall in BERLIN; Writing by Michael Georgy; Editing by Paul Tait)