The security guard was injured in the incident at the Cure International hospital and detained by police, officials said, adding that the motive behind the shootings was not immediately known.
“As a result of shooting by a security guard of the Cure hospital… three foreign nationals have been killed and one female medical staff injured,” a statement from the interior ministry said.
“The incident happened at around 9:50 this morning and the attacker has been injured and detained by police. The motive behind this attack is not clear yet.”
Cure International is a non-profit organisation founded in 1998 and based in Pennsylvania.
It operates hospitals in 29 countries, and specialises in treating children with conditions including clubfoot, cleft lips, burn injuries and brain diseases.
A doctor who was treating the wounded at the hospital in west Kabul confirmed the incident and said a foreign doctor was among the dead.
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 (AP) photographer Anja Niedringhaus was shot dead by a police commander in the eastern province of Khost in an attack which 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.
There was no immediate comment from Taliban spokesmen on Thursday’s hospital attack.
Preliminary results from the April 5 election are due to be released on Saturday, with former foreign minister Abdullah Abdullah ahead of his main rival Ashraf Ghani after half of the ballots were counted.
The incoming president will have to impose security as 51,000 foreign troops pull out by the end of this year, as well as strengthening an economy reliant on declining aid money.
Eight candidates ran in the election, with polling day hailed a success by Afghan officials and foreign allies as the Taliban failed to launch a major attack despite threats to disrupt the vote.