* Taliban gunmen storm guesthouse in upmarket Kabul
* Four trapped foreigners escape unharmed
* One Afghan child killed in latest audacious raid
* Militants up attacks as April 5 election nears (Adds siege over, quotes)
By Mirwais Harooni and Hamid Shalizi
KABUL, March 28 (Reuters) - 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 denounces 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 insurgents forced their way in. There were no casualties among foreigners.
A Reuters 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, commander of 111 Military Corps Kabul, told Reuters.
"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 organisation using the guesthouse said four people had been held hostage by the Taliban as their colleagues made frantic phone calls to establish if 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."
TALIBAN ON THE ATTACK
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 spiralled 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 nation of 30 million is holding an election to choose a successor to outgoing President Hamid Karzai, who is barred by the constitution 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. (Writing by Maria Golovnina; Additional reporting by Jessica Donati; Editing by Mike Collett-White)