Image copyright AFP Image caption The Afghan military is battling to stop the Taliban controlling Kunar province

Taliban fighters have killed 21 Afghan soldiers in an attack on a checkpoint in Kunar province close to Afghanistan's border with Pakistan.

At least one of the attackers was also killed and the Taliban told the BBC they had captured seven soldiers.

Afghan President Hamid Karzai postponed a planned visit to Sri Lanka on Sunday because of the attack.

The violence comes ahead of presidential elections that are due to be held in April.

The BBC's Karen Allen in Kabul says it is one of the deadliest Taliban attacks against the army in the past year.

Gen Mohammad Zahir Azimi said "hundreds" of insurgents had been involved in the attack, which took place in the remote Ghazi Abad district of eastern Kunar province early on Sunday.

Heavy fighting is said to have continued for several hours.

'Infiltrators'

Kunar Governor Shuja Ul Mulk told the BBC it was possible that Taliban infiltrators in the army had helped organise the attack.

Mr Karzai's office said in a statement: "The Afghan president is saddened by this tragic incident, and therefore he postponed today's official trip to Sri Lanka."

The government also confirmed that soldiers were missing, but put the number at six.

Militants have escalated attacks in recent months ahead of the withdrawal of foreign troops at the end of 2014.

Casualties among Afghan troops have been rising significantly since they took the lead in the war against the Taliban.

Security has been stepped up across Afghanistan ahead of April's elections.

Eleven candidates are standing to replace President Karzai, who cannot seek re-election.

The Taliban has threatened to target the campaign.

Separately, the Taliban said it had called off talks with the US about a prisoner exchange due to the "current complex political situation in the country".

A Taliban spokesman declined to elaborate.

The indirect negotiations, mediated by Qatar, are aimed at securing the release of a 27-year-old US soldier held by the Taliban since 2009. Sgt Bowe Bergdahl is the only US serviceman still missing from the conflict.

Five Taliban figures held at the Guantanamo Bay detention facility would be freed in exchange.