Image copyright AFP Image caption There are reports of casualties on both sides of the border

Troops from Afghanistan and Pakistan have exchanged fire along their border, prompting Pakistan to seal the Chaman border crossing.

Pakistan said Afghan border police opened fire on troops who were guarding a census team.

The head of a government hospital in Chaman told the BBC that at least six people have been killed and 31 injured.

A senior official in Kandahar said the Pakistani team had been counting people on the Afghan side of the border.

The two nations are divided by a porous border drawn by the British and disputed by Afghanistan.

The clash happened in Luqman and Jahangir, villages straddling the border.

A clash on this scale is rare. But ties between the two nations are tense - they accuse each other of failing to tackle militants on their soil.

Earlier this year, Pakistan shut border crossings after a spate of attacks it blamed on militants from over the border.

Image copyright EPA Image caption Chaman border crossing, north of regional capital Quetta, serves as a gateway to southern Afghanistan's central city of Kandahar

In a statement, Pakistan's military said that Afghan authorities had been informed in advance about the census work. It accused Afghan border police of "creating hurdles" for the census.

But Samim Khpalwak, a spokesman for the governor of Kandahar province, said the Pakistani team had strayed across the border.

A spokesman for Kandahar police told Reuters news agency that the Pakistani team were using the census as cover for ""malicious activities and to provoke villagers against the government".

At least two Afghan border police are reported to have been hurt.

How rare is this? By M Ilyas Khan, BBC News, Islamabad

Skirmishes on Pakistan's border with Afghanistan have not been as frequent as on its eastern border with India but there have been occasional firefights, mostly due to a disputed border.

The border, called the Durand Line, virtually disappeared during the 1980s when Pakistan-based militant groups fought a decade-long war against the Soviet Union in Afghanistan.

Since 2007, when some groups spawned by Pakistan-based militant networks turned hostile towards Islamabad, Pakistan has made efforts to firm up its border vigilance. This has caused several fatalities on both sides of the border.

The border became particularly tense after the Army Public School massacre in Peshawar in December 2014, when Pakistan started pushing Afghan refugees out of the country. In June last year, a series of skirmishes sparked by Pakistan's attempt to build a gate on Torkham border led to several casualties, including a Pakistan army captain.

In February this year, Pakistani troops resorted to heavy shelling of Afghan territory in Nangarhar region, saying the area was hosting anti-Pakistan militants. Afghan officials reported several deaths on their side and the dislocation of people from villages close to the border.

The Pakistani move came after the bombing of a Sufi shrine in southern Pakistan in which over 80 people were killed.