ISLAMABAD, Pakistan - Pakistani and Afghan forces exchanged fire at their rugged border in their most serious skirmish in years.

Pakistan said it killed five Afghan soldiers in the fighting Sunday but Afghanistan said just two Afghan civilians died.

Tension has been running high between Afghanistan and Pakistan, its eastern neighbour, over controlling the 2,430-kilometre border and stemming the flow of Taliban and al Qaeda militants that stage cross-border attacks inside Afghanistan. Pakistan's move to fence parts of the disputed frontier has also angered Afghanistan.

Pakistan army spokesman Maj.-Gen. Waheed Arshad accused the Afghan army of sparking the two-hour gunbattle with "unprovoked'' fire at about six Pakistani border posts in Kurram Agency, a Pakistani tribal region opposite Afghanistan's Paktia province.

A Pakistan military statement said troops from its Frontier Corps returned fire and five Afghan National Army soldiers were killed. Arshad initially put the toll at six or seven and said three Pakistani troops were wounded.

"This was unprovoked and without any reason,'' Arshad said.

On the Afghan side, Defence Ministry spokesman Gen. Mohammad Zahir Azimi accused Pakistani forces of encroaching two to three kilometres inside Paktia province's Jajai district.

"Border police tried to stop them and the Pakistani army started firing heavy weapons toward the Afghan forces,'' he told a news conference.

Two students were killed, and three students and two police were wounded, he said. Earlier, the chief of Afghan border police, Gen. Abdul Rahman, said five police were wounded.

Paktia Gov. Rahmatullah Rahmat said heavy weapons fire hit the village Kubki and a school, bazaar and clinic in Gul Ghundi village, wounding villagers and students.

"The Pakistanis launched artillery, shot their guns, and they left behind civilian casualties in the area. It is a clear violation -- crossing the border to attack Afghanistan,'' Rahmat said.

He said Afghan forces only fired back with assault rifles.

Azimi said thousands of local people had gone to join the Afghan forces after the clash, which he described as the worst in years between the two countries.

The Pakistani side later denied its forces had entered Afghan territory or hit civilian targets.

The incident is expected to enflame already acrimonious relations between the two countries -- just two weeks after a reconciliation meeting between Pakistan President Gen. Pervez Musharraf and Afghan President Hamid Karzai in Turkey where they agreed to jointly fight terrorism.

Afghanistan accuses Islamabad of harbouring and helping supporters of the former Taliban regime ousted in late 2001, which Pakistan denies.