An American soldier left his base in Afghanistan and went from house to house in two villages, killing 16 people in their homes, Afghan officials told CNN Sunday.
The dead include nine children and three women, plus five wounded, President Hamid Karzai said.
"The murdering of innocent people intentionally by an American soldier is an act of terror that is unforgivable," Karzai said.
The incident looks likely to inflame tensions still further between foreign troops and Afghan civilians, many of whom were enraged by the burning of Qurans by American troops last month.
American officials from President Barack Obama down called the burning an accident and apologized for it, but riots left dozens dead, including six American troops. Hundreds more Afghans were wounded.
Obama has been briefed on Sunday's shootings, two administration officials said.
"The soldier goes to the villages of Alokozai and Barakzai and attacks four houses, in which he kills 16 civilians and wounded others," said Haji Agha Lali, a member of the provincial council who said he he had just been the area.
NATO's International Security Assistance Force confirmed that a soldier had gone off base and fired on civilians before turning himself in, but did not say how many victims there had been.
There has been confusion about the number of casualties since the shooting in Kandahar province, eastern Afghanistan, with different sources offering different numbers.
Capt. Justin Brockhoff of ISAF said there had been "multiple" casualties and that the injured Afghans were being treated in ISAF facilities.
ISAF commander Gen. John Allen said the "deeply appalling incident in no way represents the values of ISAF and coalition troops or the abiding respect we feel for the Afghan people."
"I am absolutely dedicated to making sure that anyone who is found to have committed wrongdoing is held fully accountable," he said.
Acting U.S. Ambassador James Cunningham said his country was "saddened by this violent act against our Afghan friends."
"We deplore any attack by a member of the U.S. Armed Forces against innocent civilians," he said in a video statement, assuring "the people of Afghanistan that the individual or individuals responsible for this terrible act will be identified and brought to justice."
Seh. Harry Reid, the Senate Majority Leader, said American troops were "under tremendous pressure in Afghanistan," but that "no one can condone or make any suggestion that what (the service member) did was right because it was absolutely wrong."
Reid, a Nevada Democrat, said on CNN's "State of the UInion" that the United States was "on the right track to get out of Afghanistan just as soon as we can."
Sen. John McCain, the top Republican on the Senate Armed Services committee, said: "It is one of those things that you cannot explain except to extend your deepest sympathy to those victims and see that justice is done."
He was speaking on Fox News Sunday.
The Taliban claimed that 50 people had been killed, but the Islamist militia regularly exaggerates casualty figures.
They disputed ISAF's version of events, saying several soldiers went on a raid that resulted in dozens of deaths.
But Maj. Jason Waggoner, another ISAF spokesman, said: "The civilian casualties were not the result of any operations. The soldier was acting on his own. After the incident he returned to the compound and turned himself in."
Brockhoff said officials do not yet have a motive for the shooting, which is under investigation by both NATO and Afghan officials.
Civilian casualties as a result of action by the NATO-led international coalition have long caused anger in Afghanistan, adding pressure on international forces to withdraw.
The international force has said avoiding civilian casualties is a high priority.
"My command's mission is to protect the civilian people of Afghanistan," Gen. Allen said last month. "I take very seriously the loss of every Afghan life. We will continue to do all we can to ensure the safety of the Afghan population."
The number of ISAF-caused civilian deaths decreased by nearly 17% from 2010 to 2011, the coalition force said in its December monthly report.