Pakistani and Afghan troops have exchanged fire for several hours along their disputed border, officials on both sides say, as tension between the neighbours flared into deadly violence.
Pakistan's military said a census team - guarded by troops from its Frontier Corps (FC) - that was collecting population data in a village near the border town of Chaman came under fire and at least one person was killed and 18 wounded.
Zia Durani, police spokesman for Afghanistan's Kandahar province, said Pakistani officials were using the census as a cover for "malicious activities and to provoke villagers against the government".
"They did not heed the warning and we have clear orders to engage them," Mr Durani said, adding two Afghan border police were wounded.
Kandahar police chief General Abdul Raziq said 40 Pakistani soldiers and 37 others were killed, including 14 Afghan border police. Reuters was unable to confirm the figures.
Violence ceased later in the day and officials from both sides were due to meet at the frontier, the Pakistani military said. Pakistan's foreign ministry summoned the Afghan charge d'affaires to protest at what it called unprovoked firing.
The Chaman crossing into Afghanistan's Kandahar province is one of two border points. A doctor in a Chaman hospital told Reuters three people had been killed in the fighting.
Relations between the countries have been uneasy since Pakistan's independence in 1947. Afghanistan has traditionally enjoyed better ties with Pakistan's rival, India.
Afghanistan has for years accused Pakistan of sheltering Afghan Taliban militants, something Pakistan denies.
Pakistan's military said Afghan border police had been "creating hurdles" since April 30 for the census team in the Chaman area.
"This was done despite the fact that Afghan authorities had been informed well in advance and coordination was carried out through diplomatic and military channels for conduct of the census," the military said.