The shooting took place in Gardez, capital of eastern Paktia province, Gen. Mohammad Zahir Azimi, an Afghan Defense Ministry spokesman, said. The area, near the border with Pakistan, has been a front line in fighting with the Taliban and other militants.
The attack took place inside a base of the Afghan army in the city, according to a security official in Gardez, who spoke on condition of anonymity because he was not authorized to give details while the incident was still under investigation.
A U.S. Defense Department official confirmed that all three soldiers were Americans, but that no further details would be released until after their relatives had been notified. NATO said the shooting was carried out by a gunman wearing the uniform of the Afghan National Security Forces, but it gave no further details.
Killings by uniformed Afghans of foreign soldiers and civilians rose dramatically last year, eroding confidence between the sides at a crucial turning point in the conflict. So-called insider attacks killed 62 personnel in 47 incidents last year compared to 35 killed in 21 attacks a year earlier, according to NATO.
So far in 2013, 11 foreign soldiers have been killed in seven such attacks, including Saturday's, according to an Associated Press count.
In some cases, militants have donned Afghan army or police uniforms to attack foreign troops, but a number have been carried out by members of Afghan security forces against their own comrades.
The attacks come as NATO and Afghan forces are in more intimate contact, with foreign troops handing over security to the Afghans and continuing to train them prior to an almost total withdrawal by the end of 2014.
Associated Press Writer Douglass K. Daniel in Washington D.C. contributed to this report.