Taliban gunmen stormed a Kabul guesthouse used by a U.S.-based aid group and held four foreigners hostage for several hours on Friday, just eight days before Afghanistan holds a presidential election which the militant group has vowed to derail.

Kabul is already on high alert and people across the country are on edge ahead of an April 5 vote the hardline Islamist movement has denounced as a Western-backed sham. The siege of the walled compound, which is also home to a small church, lasted several hours before Afghan security forces killed the last remaining Taliban gunman holed up inside.

At least one Afghan child was killed when a suicide bomber blew himself up outside the building and the insurgents forced their way in. There were no foreign casualties. A witness saw about 20 people being evacuated from the guesthouse in an upmarket residential area of Kabul, many looking frightened and shocked.

"The fight is over. The five attackers are dead," Qadam Shah Shaheem, said the commander of 111 Military Corps Kabul. "One detonated his car loaded with explosives, three others detonated explosives attached to their bodies inside the building, and one was shot by security forces. All four foreigners are alive and safe now."

The country manager of an organization using the guesthouse said four people had been held hostage by the Taliban as their colleagues made frantic phone calls to establish whether they were alive.

"I can confirm it was attacked and that there are only four people" inside, said Hajji Mohammad Sharif Osmani, country manager of Roots of Peace, a U.S.-based group involved in demining and other projects in Afghanistan. "The rest of the guys are outside."

Marie Harf, a spokeswoman for the U.S. State Department, said there had been two U.S. citizens in the guesthouse, and both were safe. She said she did not know if they had been among those held hostage.

"We condemn this attack on Roots of Peace ... an organization that only seeks to help Afghans improve their lives and their livelihoods," Harf told a regular news briefing in Washington, adding that the organization is supported by the U.S. government.

"Again, the Taliban's actions demonstrate the growing distance between them and the Afghan people," Harf said. "A large majority of Afghans reject what the Taliban is trying to sell them. They reject this kind of violence and fear and intimidation and want to go to the polls."

The attack was a chilling reminder to Afghan voters and foreigners of the kind of assault the Taliban are capable of mounting in the heavily guarded Afghan capital after their leaders ordered fighters to disrupt the election. Violence has spiraled in Afghanistan in recent weeks with almost daily explosions and gunfights around the country.

Taliban suicide bombers and gunmen attacked an election commission office in Kabul on Tuesday, and last week, nine people including an AFP journalist and an election observer, were killed in an attack on a highly fortified hotel in the capital.

The Taliban claimed responsibility for Friday's assault, saying in a statement that the target was a foreign guesthouse and a church. The country of 30 million is holding an election to choose a successor to outgoing President Hamid Karzai, who is constitutionally barred from running for another term in office.

It will be seen as a major test by foreign donors who are hesitant about bankrolling the government after the bulk of NATO troops stationed in Afghanistan withdraw later this year.