A suicide bomber on a bicycle killed nine people outside the defence ministry in central Kabul on Saturday during a visit to the Afghan capital by new US Defense Secretary Chuck Hagel.
The blast occurred near the main entrance gate of the heavily-guarded ministry, and Taliban militants immediately claimed the attack was timed to send a message to Hagel, who arrived in Kabul late on Friday.
One Afghan soldier covered in blood at the scene said he had helped carry five people from the attack site, where several cars were damaged and a wall was left pock-marked.
Hagel, a decorated Vietnam war veteran, was at a US facility less than a mile from the attack when the loud explosion followed by gunfire was heard across Kabul.
"I wasn't sure what it was," he told reporters afterwards. "I was in a briefing. We are in a war zone and I have been at war. We should not be surprised when bombs go off."
Zahir Azimi, spokesman for the Afghan defence ministry, told reporters at the scene that the bomber had arrived on a bicycle and detonated himself 30 metres (100 feet) from the ministry gate.
Police said in a statement that nine civilians had died and 13 others were injured including two military personnel, without giving further details.
Taliban spokesman Zabiullah Mujahid told AFP: "This was not a direct attack to target him (Hagel) but we want to send a message that we are always capable of hitting Kabul even when the top US defence official is there."
Hagel arrived in Kabul as the international military coalition prepares to pull out by the end of next year and leave Afghan security forces to battle the Taliban insurgency that has raged across the south and east of the country.
"We're seeing a world in great transition, just like the transition under way here in Afghanistan," he told troops on a brief visit to a base in Jalalabad.
"We see through those challenges and find opportunity to help make a better world."
Hagel was sworn in 10 days ago as heavy cuts loom for the US military, but he said Americans realised that Afghanistan remained a major conflict zone with US troops fighting against Islamist militants since the 9/11 attacks.
A total of 100,000 NATO-led international troops are currently deployed in Afghanistan, with all combat forces due to exit by the end of 2014.
US President Barack Obama last month announced that 34,000 US troops would withdraw in the next year, halving the size of the current 66,000-strong US force.
Afghan forces are assuming control of security across the country, but there are widespread fears that they will be unable to face down the Taliban and that the country could tip into greater instability.
In another suicide attack on Saturday, eight children and a policeman were killed in the eastern city of Khost in a strike that targeted a joint Afghan and international troop patrol.
A ceremony to mark the complete transfer of Bagram jail from US to Afghan control was cancelled on Saturday in another setback in a long-running dispute over detainees.
NATO officials said full agreement had not yet been reached on the transfer of suspected militants.