The Taliban struck back less than two hours after President Barack Obama left Afghanistan on Wednesday, targeting a foreigners' housing compound with a suicide car bomb and militants disguised as women in an assault that killed at least seven people.

It was the second major assault in Kabul in less than three weeks and highlighted the Taliban's continued ability to strike in the heavily guarded capital even when security had been tightened for Mr. Obama's visit and Wednesday's anniversary of the killing of al-Qaeda leader Osama bin Laden in neighbouring Pakistan.

Mr. Obama arrived at Bagram Air Field late on Tuesday, then travelled to Kabul by helicopter for a meeting with President Hamid Karzai in which they signed an agreement governing the U.S. presence after combat troops withdraw in 2014. Later, he was back at the base, surrounded by U.S. troops, shaking every hand. He then gave a speech broadcast to Americans back home, before ending his lightning visit just before 4.30 a.m.

The U.S. President, who is in the midst of a re-election campaign, touted the Navy SEAL raid that killed bin Laden a year ago on Wednesday, noting that the operation was launched from a base in Afghanistan.

“We broke the Taliban's momentum. We've built strong Afghan security forces. We devastated al-Qaeda's leadership, taking out over 20 of their top 30 leaders,” he said.

But the violence that erupted about 90 minutes after his departure was a stark reminder of the difficult task still ahead for Afghan troops as they work to secure their country after U.S. and other foreign troops end their combat mission following nearly a decade at war.

The deal signed with Mr. Karzai does not commit the United States to any specific troop presence or spending. But it does allow the U.S. to potentially keep troops in Afghanistan through 2024 for two specific purposes — continued training of Afghan forces and targeted operations against al-Qaeda.

The United States also promises to seek money from Congress every year to support Afghanistan.

The attack began with a suicide car bomb near the gate of the privately guarded compound, which sits off Jalalabad road one of the main thoroughfares out of the city, said Interior Ministry spokesman Sediq Sediqi.

Kabul Deputy Police Chief Daoud Amin said those killed in the blast included four people in a station wagon that was driving past the area, a passer-by and a Nepalese security guard. The Interior Ministry said 17 other people were wounded, many Afghan children on their way to school.

Mr. Karzai's office said three Taliban militants took part in the attack — the suicide car bomber and two other gunmen who stormed the compound disguised in burkas.

Explosions and gunfire shook the city for hours as Afghan soldiers rushed to the scene and battled the attackers.

The Taliban later announced that its annual “spring offensive” would begin on Thursday. The offensive comes every year as the snows melt, making both travel and fighting easier as the Taliban try to retake lost territory.

More In: International | News