Taliban insurgents set off a truck bomb on Tuesday in an attack on Afghan army commandos, killing three people and wounding 41, the defence ministry said, despite steps towards peace talks with the US-backed government.
The Taliban claimed responsibility for the blast in the northern province of Balkh, saying on Twitter they had attacked the commandos.
The defence ministry said two members of the commando force were killed and six wounded, while the rest of the casualties were civilians.
The blast came as a Taliban delegation visited the Pakistani capital to discuss a peace process underpinned by an agreement between the Taliban and the United States on the withdrawal of US forces in exchange for Taliban security guarantees and a promise to open power-sharing talks with the government.
But despite what many Afghans see as the best hope for peace since the latest phase of Afghanistan's war began in 2001, the level of violence has remained high.
Diplomats and officials say the violence is sapping the trust needed for talks.
The government has asked repeatedly for a ceasefire before negotiations start in Qatar's capital of Doha, a request the Taliban have refused.
Diplomats say Pakistan, which has long had influence over different Afghan factions, including the Taliban, has in recent months been pushing for a reduction in violence.
It was not immediately clear what issues would be discussed in the talks between the Taliban and the Pakistanis in Islamabad.