KABUL - Taliban militants on Friday attacked a Kabul guesthouse used by a US anti-landmine charity, killing two people including one girl as gunfire and explosions rocked the Afghan capital one week before the presidential election.

A terrified group of foreigners, including several young children, briefly took shelter behind a generator on the street as Afghan special force commandos fought militants for more than three hours.

“One small Afghan girl, who was a passer-by, has been killed. We managed to safely evacuate 31 foreign nationals from inside the building,” Kabul police chief Mohammad Zaher told AFP.

The interior ministry spokesman said one driver had also been killed.

Roots of Peace’s country director Sharif Osmani confirmed its guesthouse had been attacked, adding that three Afghans were injured and that three people had been trapped inside before being rescued.

The charity, based in San Francisco, has been working in Afghanistan since 2003, running projects to turn minefields into vineyards and orchards.

Friday’s attack is the fourth significant attack this year in Kabul targeting foreigners or places where foreigners congregate.

The Taliban have vowed a campaign of violence to disrupt the polls on April 5, urging their fighters to attack polling staff, voters and security forces in the run-up to election day.

Friday’s assault, involving five attackers, began with a car bomb detonated in front of the building and continued until after dark as commandos hunted down attackers inside the compound.

“Roots of Peace has been a valued partner for Afghanistan, with the support of USAID,” US Ambassador James Cunningham said on Twitter.

“We condemn this attack on an organization that only seeks to help Afghans improve their lives and livelihoods.”

Afghan police said two Americans, a Peruvian, a Malaysian and an Australian were among those rescued, and that all five attackers had been killed.

There was no immediate confirmation of nationalities.

The Taliban claimed responsibility for the attack, and said the target was a foreign guesthouse that they alleged was also used as a church.

Roots of Peace clears minefields laid during the Soviet occupation of the 1980s and the civil war of the 1990s and to convert the land for agricultural use.

Since 1989, when Soviet forces left Afghanistan, more than 4,000 people have been killed and 17,000 injured by mines, according to an estimate by the UN’s Mine Action Coordination Center of Afghanistan.

The assault comes just three days after Taliban militants stormed an office of the Independent Election Commission in Kabul, killing five people.

Last Thursday four Taliban gunmen smuggled pistols into Kabul’s high-security Serena hotel and shot dead nine people including four foreigners.

The victims also included Agence France-Presse journalist Sardar Ahmad, his wife and two of their three children.

Those attacks followed the daylight shooting of a Swedish radio journalist and an assault in January on a Lebanese restaurant that killed 21 people including 13 foreigners.

The vote to choose a successor to President Hamid Karzai, barred constitutionally from seeking a third term, will be Afghanistan’s first-ever democratic handover of power.

But there are fears of a repeat of the bloodshed that marred the 2004 and 2009 elections, when the Taliban displayed their opposition to the US-backed polls through violence.

Another bloody election would damage claims by international donors that the expensive intervention in Afghanistan has made progress in establishing a functioning state.

The surge in attacks on foreigners in Kabul will also raise fears that independent poll monitors will be unable to work effectively, threatening the credibility of the April 5 vote.

A disputed result would put whoever wins the election in a weak position as Afghan security forces take on the Taliban without NATO’s 53,000 combat troops behind them.

US-led NATO combat troops are withdrawing from the country after 13 years of fighting the Islamist insurgency, which erupted when the Taliban were ousted from power after the 9/11 attacks on the United States.