Gen. Harold Greene, the most senior US soldier killed in action overseas since Vietnam, was shot dead as he visited a UK-run military training facility.
Afghan President Hamid Karzai said the shooting was a “cowardly attack”.
Officials said the Afghan soldier who opened fire in the insider attack had been shot dead.
Insider attacks have become one of the defining features of the later phase of the conflict in Afghanistan.
They have hampered efforts to train the country’s 350,000-strong security force as they prepare to take on the Taliban once most US and NATO forces depart.
Tuesday’s attack is the most high profile.
Along with Gen. Harold Greene, at least 15 other soldiers were injured.
Two British, several Americans and generals from Germany and Afghanistan were among the wounded.
US Army spokesman Juanita Chang described Gen. Harold Greene as a “true hero”.
She said he was working “to better advance the Afghans and the cause in Afghanistan”.
“He really believed what he was doing over there,” she said.
Gen. Harold Greene was a technology expert described by the New York Times as playing a key role in integrating smartphones, video conferences “and even virtual worlds into military culture”.
The newspaper said that his last promotion of his 30-year army career came earlier this year when he was deployed to Afghanistan to oversee the military handover from American to Afghan control as US forces begin withdrawing from the country.
Correspondents say that the attack raises new doubts about NATO’s ability to train Afghan forces as Western countries gradually withdraw.
The Pentagon described “insider attacks” as a “pernicious threat”.
From the end of this year just under 10,000 American troops will remain, with all withdrawing by the end of 2016.
The Pentagon described it as an isolated attack and insisted that there has been no breakdown of trust between coalition soldiers and their Afghan counterparts.
The Afghan soldier who opened fire was recruited three years ago.
He carried out the shootings from a guard post at a large group of senior Afghan and international troops.
By the time he had emptied the magazine of his US-issue M16 rifle, more than a dozen people had been shot, our correspondent says.
The Afghan commander of the British-led officers’ academy, Gen, Gulam Sakhi, was among those wounded.
fvt1c-0PDVEMillions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…
Misleading allegations, rumours and outright lies about voting and fraud are flooding online spaces in…