And, in a possible blow to US efforts to foster peace talks to end the long Afghan conflict, a Taliban spokesman said the group had suspended its efforts to arrange a possible exchange of Taliban and US prisoners due to the "complexity" of the situation in Afghanistan.
It was not immediately clear whether the attack in the eastern province of Kunar was related to the suspension of talks on a prisoner swap.
In response to the killings in Kunar, a mountainous region bordering Pakistan that has long been a stronghold of the Taliban, al Qaeda, and other militants, President Hamid Karzai cancelled a trip to Sri Lanka.
His 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."
Mr Karzai's officials said 21 soldiers were killed and three were wounded in the attack on an army checkpoint in Kunar's Ghaziabad district. Six remained missing.#
The government sent reinforcements to the area where the pre-dawn attack took place and they came under attack, including from a suicide bomber who detonated his explosives near them, but no Afghan troops died in the follow-up attack.