attackers dressed in burqas detonated a suicide car bomb and clashed with guards at the "Green Village" complex of guesthouses used by foreign organisations including the European Union, the United Nations and aid groups, officials said.
The attackers' ability to penetrate a tightened security cordon in the capital raises fresh concern about the resilience of the insurgency as NATO hands over responsibility for security across the country to Afghan forces and winds down its combat presence in the next two years.
The Taliban claimed responsibility for the assault and said it was a riposte to Obama, just hours after he signed a new partnership pact set to govern Afghan-US relations after 2014.
In an election-year address, Obama presented himself as a commander-in-chief capable of ending two long wars, following the US troop withdrawal from Iraq, and of crushing Al-Qaeda, and tried to conjure up a new dawn for a US public exhausted by conflict and recession.
"This time of war began in Afghanistan, and this is where it will end," Obama said, recalling a decade-long "dark cloud of war" after bin Laden plotted the September 11 attacks in 2001.
"Yet here, in the pre-dawn darkness of Afghanistan, we can see the light of a new day on the horizon," said Obama, seeking a second White House term later this year.
Obama flew into Kabul in secret in the dead of night and signed a deal with President Hamid Karzai, cementing 10 years of US aid for Afghanistan after NATO combat troops leave in 2014.
"We look forward to a future of peace. We're agreeing to be long-term partners," Obama said at the signing ceremony at Karzai's palace. The US president left after six hours on the ground. About two hours later, the Green Village assault began.
Police said suicide attackers wearing burqas first blew up a car bomb, then clashed with guards. The interior ministry said seven people were killed, including a student and a security guard.
Kargar Noorughli, spokesman for the health ministry, said 18 people were wounded and eight admitted to hospital, including one in a critical condition and "several children".
"It is a message to Obama that he and his forces are never welcomed in Afghanistan and that we will continue our resistance until all the occupiers are either dead or leave our country," Taliban spokesman Zabiullah Mujahid told AFP.
After several hours of fighting, NATO said all of the attackers had been killed.
Tuesday's assault came just over two weeks after one of the largest attacks in Kabul, where squads of militants targeted government offices, embassies and foreign bases more than 10 years after the Taliban were driven from power for refusing to hand over bin Laden.
Karzai said the US pact was no threat to any third country and he hoped it would lead to stability in the region.
Neighbouring Pakistan has long been seen as a source of instability in Afghanistan, and its relationship with both Kabul and Washington remains mired in mistrust a year after bin Laden was found and killed by US commandos on its soil.
The White House said the US-Afghan pact sees the possibility of American forces staying behind to train Afghan forces and pursue the remnants of Al-Qaeda for 10 years after 2014.
It does not commit Washington to specific troop or funding levels for Afghanistan, though is meant to signal to US foes that despite ending the longest war in US history, Washington intends to ensure Afghanistan does not revert to a haven for terror groups like Al-Qaeda.
But after a war that has cost the lives of nearly 3,000 US and allied troops, thousands of Afghans and cost hundreds of billions of dollars, Afghanistan's future is deeply uncertain.
Furious Republicans have accused Obama of exploiting the Navy SEAL special forces who conducted the raid to kill bin Laden in the Pakistani garrison town of Abbottabad on May 2 last year.
But the president, who faces a tough re-election fight, did not shirk from presenting himself as the man to shepherd his country out of war and economic crisis at home. Yet US troops could be fighting for two more years, and some could remain in danger for a decade after that.
Obama bluntly told US soldiers that "some of your buddies are going to get injured, some of your buddies may get killed".
A Pentagon report issued Tuesday said security had improved in most of Afghanistan but conceded that insurgent sanctuaries in Pakistan and corruption pose "long-term and acute challenges".
About 87,000 US troops and 44,000 other international forces are deployed in Afghanistan along with 344,000 Afghan army and police, the report said.
The deal signed by Obama and Karzai was concluded just over two weeks before a NATO summit in Chicago.
On Monday, Obama had publicly questioned whether his Republican opponent Mitt Romney would have taken the same decision as he did to launch the audacious raid that killed bin Laden in Pakistan.
Romney welcomed Obama's visit, saying US soldiers and public needed to hear what was at stake in Afghanistan.