The blast occurred near the main entrance gate to 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.
Gunfire erupted after the loud explosion was heard across Kabul as streets around the blast were closed off by security forces.
Hagel was at a US facility in the city less than a mile from the attack but reporters travelling with him were informed that he was not under any threat.
“The secretary was in a briefing when the incident occurred. The briefing continued as planned without interruption,” a spokesman for the Pentagon chief said.
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 have a lot of big issues and challenges ahead as we prepare for a responsible transition,” he told reporters on his plane before he arrived.
“That transition has to be done right, it has to be done in partnership with the Afghans (and) with our allies.”
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.
“We have 66,000 troops still at war in a combat zone, that reality is there,” he said. “I don’t minimise or marginalise anything just because we may be transitioning to a new phase, we’re still at war in Afghanistan.”
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.
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.