Two of the dead Americans were a father and son, Minister of Health Soraya Dalil said, adding that the third American was a Cure International doctor who had worked in Kabul for seven years.
Dalil said an American nurse was also wounded in the attack.
"A child specialist doctor who was working in this hospital for the last seven years for the people of Afghanistan was killed and also two others who were here to meet him, and they were also American nationals," Dalil said. "The two visitors were father and son, and a woman who was also in the visiting group was wounded."
The attacker was a member of the Afghan Public Protection Force assigned to guard the hospital, according to District Police Chief Hafiz Khan. He said the man's motive was not yet clear.
The gunman, who was detained, was wounded during the attack and underwent surgery at midday in the same medical facility under heavy police guard, according to Kanishka Bektash Torkystani, a Ministry of Health spokesman.
Later in the afternoon, Dalil, the health minister, said he was recovering from the surgery before being questioned. Initial reports indicate he was shot by other security forces, said Ministry of Interior spokesman Sediq Sediqqi.
"Five doctors had entered the compound of the hospital and were walking toward the building when the guard opened fire on them," Torkystani said. "Three foreign doctors were killed."
The U.S. Embassy in Kabul confirmed that three American citizens had been killed in the hospital attack but said it had no other information. It did not confirm Afghan reports that the three were doctors.
According to its website, the Cure International Hospital was founded in 2005 by invitation of the Afghan Ministry of Health. It sees 37,000 patients a year, specializing in child and maternity health as well as general surgery. It is affiliated with the Christian charity Cure International, which operates in 29 countries with the motto "curing the sick and proclaiming the kingdom of God."
The Afghan capital has seen a spate of attacks on foreign civilians in 2014, a worrying new trend as the U.S.-led military coalition prepares to withdraw most troops by the end of the year.
It was unclear whether the Taliban were behind Thursday's shooting, though the insurgents have claimed several major attacks that killed foreign civilians this year, an escalation of such attacks after years of mostly targeting foreign military personnel and Afghan security forces.
In January, a Taliban attack on a popular Kabul restaurant with suicide bombers and gunmen killed more than a dozen people, while in March gunmen slipped past security at an upscale hotel in the Afghan capital and killed several diners in its restaurant. Two foreign journalists were killed and another wounded in two separate attacks.
The hospital shooting is also the second "insider attack" by a member of Afghan security forces targeting foreign civilians this month.
On April 4, an Afghan police officer shot two Associated Press staff working in the eastern province of Khost, killing photographer Anja Niedringhaus and wounding veteran correspondent Kathy Gannon.
Violence and insecurity have been spiraling in Afghanistan amid uncertainties surrounding the April 5 presidential election and the upcoming withdrawal at the end of the year of most international troops. An international military coalition has been in Afghanistan since the 2001 U.S.-led invasion to oust the Taliban's hard-line Islamic government for sheltering al-Qaida leaders in the aftermath of the Sept. 11, 2001, terrorist attacks.
Also on Thursday, Afghan officials said security forces rescued a deputy minister who had been abducted last week in Kabul. Ahmad Shah Wahid, the deputy minister of public works, was found alive in the eastern province of Kapisa after being moved twice by his captors, according to provincial government Mehrabdin Safi.
Acting on intelligence that Wahid had been moved to the area and was about to be moved again, authorities set up checkpoints on major roads. When the kidnappers, who have not been identified, were stopped at one checkpoint, they fled on foot, leaving Wahid behind in the car, Safi said.
"He is fine now," Safi said of Wahid. "We have sent him to Kabul back to his family."