An Afghan policeman has opened fire on staff at a Kabul hospital run by a US charity, killing three Americans in the latest deadly attack targeting foreign civilians in the city.

The gunman was injured in the incident outside the Cure International hospital and detained by police, officials said, adding that the motive behind the shooting was not known.

"The attacker was a member of the police in the district," Seddiq Sediqqi, spokesman for the interior ministry, told AFP.

"He opened fire as the foreign nationals were entering the hospital, tragically killing three and injuring one more. Another policeman in the area shot the attacker, injuring him."

A medic who was treating the wounded told AFP that a foreign doctor was among the dead.

"With great sadness we confirm that three Americans were killed in the attack on Cure Hospital," the US embassy said on its Twitter account. 

"No other information will be released at this time."

Kabul has been hit by a spate of attacks targeting foreign civilians this year, including a Lebanese restaurant where 21 people died, an attack on a luxury hotel and the daylight shooting of a Swedish radio journalist.

Last month Taliban militants attacked a Kabul guesthouse used by Roots of Peace, a US anti-landmine charity, killing two people, including a girl.

And this month Associated Press photographer Anja Niedringhaus was shot dead by a police commander in the eastern province of Khost in an attack that also left her Canadian colleague Kathy Gannon badly wounded.

That killing came on the eve of presidential elections to choose a successor to Hamid Karzai as US-led combat troops withdraw from Afghanistan after 13 years of fighting Taliban insurgents.

Cure International is a non-profit organisation founded in 1998, based in Pennsylvania and working in 29 countries including conservative Muslim Afghanistan.

It describes itself as an " unapologetically Christian organisation" on its website, adding that it offers "treatment regardless of gender, religion, ethnicity, or ability to pay".

Its hospitals and health programmes specialise in treating children with conditions including clubfoot, cleft lips, burn injuries and brain diseases.

Cure International took over the hospital in west Kabul in 2005 at the invitation of the Afghan government.

It runs obstetrics, gynaecology, pathology and surgery departments, as well as training schemes for doctors and nurses.