President Barack Obama has called an incident in which an American soldier killed 16 Afghan civilians, including nine children, "tragic and shocking".
In a written statement, Mr Obama said: "I offer my condolences to the families and loved ones of those who lost their lives, and to the people of Afghanistan, who have endured too much violence and suffering.
"This incident is tragic and shocking, and does not represent the exceptional character of our military and the respect that the United States has for the people of Afghanistan."
The president offered his full backing to a US investigation "to get the facts as quickly as possible and to hold accountable anyone responsible".
The US leader has spoken to Afghan President Hamid Karzai, who earlier demanded an explanation for what he termed an "assassination".
US Defence Secretary Leon Panetta also assured Mr Karzai in a phone call that a "full investigation" was under way.
"A suspect is in custody, and I gave President Karzai my assurances that we will bring those responsible to justice," Mr Panetta said.
The Defence Secretary added that he is "shocked and saddened that a US service member... clearly acting outside his chain of command" has been linked to the incident.
Mr Panetta said he told Mr Karzai "that the American people share the outrage" felt by the Afghan leader and his people.
The gunman, believed to be a lone rogue soldier from Fort Lewis in Washington, went from house to house in two villages in southern Kandahar during the night.
Shooting began at around 3am, according to officials. Among the victims were at least three women, a child aged just two and elderly men.
Neighbours said the soldier had appeared drunk and relatives of the victims claimed chemicals were poured over the dead bodies to burn them. Pictures of the scene appeared to show the remains of burning in at least one of the houses.
Mr Karzai said in a statement: "This is an assassination, an intentional killing of innocent civilians and cannot be forgiven."
The gunman, reported to be an Army staff sergeant, returned to his base after the spree and is said to have turned himself in. US officials have confirmed he is in custody.
Gul Bashra, the mother of the two-year-old who died, told the Associated Press: "They [Americans] killed a child, who was two-years-old. Was this child a Taliban [member]?
"Believe me, I have not seen a two-year-old Taliban [member] yet. There is no Taliban here. They [America] are always threatening us with dogs and helicopters during night raids."
Another man said 11 of his relatives, including his children, had been killed in the shooting which took place in the Panjwayi district.
"They (Americans) poured chemicals over their dead bodies and burned them," a weeping Haji Samad told Reuters at the scene."I saw that all 11 of my relatives were killed, including my children and grandchildren."
Pictures showed blood-splattered walls where the children died.
Neighbours said they awoke to crackling gunfire from American soldiers, whom they described as laughing and drunk.
"They were all drunk and shooting all over the place," Agha Lala, who visited one of the homes where the incident took place, said. "Their bodies were riddled with bullets."
One resident, Abdul Baqi, told the Associated Press: "When it was happening in the middle of the night, we were inside our houses. I heard gunshots and then silence and then gunshots again."
An AP photographer saw 15 bodies in the two villages. Some had been burned, while others were covered with blankets.
The Panjwayi district is about 22 miles west of the provincial capital Kandahar city and is considered the spiritual home of the Taliban and a hive of insurgent activity.
International forces have fought for control of the area for years as they have tried to subdue the Taliban in their rural strongholds.
The two villages where the rampage happened, Balandi and Alkozai, are around 500m from the US base.
The Nato -led International Security Assistance Force (Isaf) confirmed the incident but did not release the number of killed or injured.
The US commander of Isaf vowed to hold "fully accountable" anyone found responsible for the "deeply appalling" killings.
"I am absolutely dedicated to making sure that anyone who is found to have committed wrong-doing is held fully accountable," General John Allen said.
Isaf Deputy Commander Lt Gen Adrian Bradshaw said: "I wish to convey my profound regrets and dismay at the actions apparently taken by one coalition member in Kandahar province.
"I cannot explain the motivation behind such callous acts, but they were in no way part of authorised Isaf military activity."
The Afghan defence ministry said: "The defence minister... is deeply shocked and saddened by the killings of 15 innocent civilians and the wounding of nine more at the hands of the Coalition forces."
The US embassy in Kabul also issued an apology, saying: "We deplore any attack by a member of the US armed forces against innocent civilians, and denounce all violence against civilians.
"We assure the people of Afghanistan that the individual or individuals responsible for this act will be identified and brought to justice."
Meanwhile, White House National Security Council spokesman Caitlin Hayden said: "We are deeply concerned by the initial reports of this incident, and are monitoring the situation closely."
The incident adds new tensions to a relationship already severely strained over US forces burning Muslim holy books on a base in Afghanistan.
Although US officials apologised and said the burning was an accident, the incident sparked violent protests and attacks.
Six American soldiers have been killed in attacks by their Afghan colleagues since the Koran burnings came to light. Britain also pulled out civilian advisers from buildings in Kabul as protests spread.
The controversy followed an outrage over a video showing US marines urinating on the bodies of dead Taliban fighters.
Sky defence reporter Mark Stone said: "It really is not good at a time when the Americans and the coalition in general are trying to extract themselves from this very difficult war."