The suicide bomber detonated explosives in a truck near an Afghan army base in Balkh province, military spokesman for the region Hanif Rezayee said.
Taliban spokesman Zabihullah Mujahid said on Twitter that the attack was revenge for a video circulating online that appeared to show Afghan troops desecrating bodies of Taliban fighters in the south.
The Ministry of Defence has launched an investigation into the video, which surfaced earlier this month.
The assault on Tuesday killed two civilians and a commando and wounded more than 40 others, Rezayee said. Many houses were damaged or destroyed and soldiers were helping to get the victims to safety, he added.
The Ministry of Defence confirmed the attack.
Afghan President Ashraf Ghani condemned the attack on the military base and urged the Taliban to begin talks.
“The Taliban’s emphasis on continuation of violence poses challenges to the peace opportunities,” Ghani said, according to his spokesman.