At least 25 Pakistani troops died during a prolonged clash after hundreds of militants crossed the Afghan border on Tuesday, officials say.

About 200 insurgents, whom police say were wearing military uniform, ambushed a security checkpoint in Upper Dir, outside Pakistan's tribal areas.

Officials said army support had arrived at the remote checkpoint.

Upper Dir, which lies just outside Pakistan's volatile tribal areas, is regularly targeted by insurgents.

The militants began their raid on the town of Shaltalo in a remote, mountainous corner of Upper Dir district, near the border with Kunar province of Afghanistan, on Tuesday.

The military used heavy weapons and helicopter gunships to repulse the attack. Witnesses say the fighting has died down but sporadic gunfire is still being heard.

A Pakistani official said full details of the fighting were not known because communications with the remote area had broken down.

Several troops are reported to be wounded and officials say that three civilians have also been killed in the clashes.

"We have regained control of most of the area but fighting is still going on in some parts near the checkpost," senior police official Qazi Jamil ur-Rehman told the AFP news agency.

It is not clear which group the militants belonged to, but correspondents say that many of the various groups along the frontier are closely linked.

Securing the long, porous border that divides Pakistan and Afghanistan has been a major challenge for the two countries as they try to battle insurgents, correspondents say.

At least 13 Pakistani security troops were killed in a similar cross-border raid by Taliban in the neighbouring Lower Dir district two months ago.