(Adds details about suspect)
* One or more U.S. troops opens fire on civilians
* Witnesses say women and children killed in homes
* Killings further inflame ties between Kabul and West
By Ahmad Nadem and Ahmad Haroon
KANDAHAR, Afghanistan, March 11 - A U.S. soldier was detained after 16 Afghan civilians, including nine children, were shot dead in what witnesses described on Sunday as a night-time massacre near a U.S. base in Afghanistan's violent south.
While U.S. officials rushed to distance the apparent rogue shooting from efforts by a 90,000-strong U.S. force in Afghanistan, the incident is sure to fan Afghan anger after U.S. soldiers inadvertently burnt copies of the Koran at a NATO base last month.
The soldier in custody was described by one U.S. official in Washington as a staff sergeant who was married with three children. The sergeant had served three tours in Iraq but was on his first deployment in Afghanistan, the official said.
Other officials in Washington said he was from a unit based in Washington state and may have originally been from the area.
Villagers in three houses were attacked and multiple civilians were wounded, a spokesman for the NATO-led International Security Assistance Force (ISAF) said.
U.S. President Barack Obama called his Afghan counterpart Hamid Karzai promising to establish the facts quickly and "to hold fully accountable anyone responsible".
There were conflicting reports about how many shooters were involved, with U.S. officials asserting that a lone soldier was responsible. Witness accounts said there were several U.S. soldiers involved.
The incident was one of the worst of its kind since U.S.-backed Afghan forces toppled the Taliban in late 2001.
The U.S. Embassy in Kabul said anti-U.S. reprisals were possible following the killings, just as the Koran-burning incident triggered widespread anti-Western protests in which at least 30 people were killed.
Neighbours and relatives of the dead said they saw a group of U.S. soldiers arrive at their village in Kandahar's Panjwai district at about 2 a.m., enter homes and open fire.
Obama said he was deeply saddened. "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," Obama said in a statement.
Karzai condemned the rampage as "intentional murders" and demanded an explanation from the United States. His office said the dead included nine children and three women.
Afghan officials also gave varying accounts. Karzai's office released a statement quoting a villager as saying "American soldiers woke my family up and shot them in the face".
Minister of Border and Tribal Affairs Asadullah Khalid said a U.S. soldier burst into three homes near his base in the middle of the night, killing a total of 16 people, including 11 people in the first house.
The ISAF spokesman said the lone U.S. soldier "walked back to the base and turned himself in to U.S. forces this morning", adding there had been no military operations in the area.
Panjwai district is about 35 km (20 miles) west of the provincial capital Kandahar city, an area considered the birthplace of the Taliban and long a hive of insurgent activity.
An Afghan man said his children were killed and accused soldiers of burning the bodies.
"I saw that all 11 of my relatives were killed, including my children and grandchildren," a weeping Haji Samad said after returning to find the walls of his home splattered with blood.
"They (Americans) poured chemicals over their dead bodies and burned them," Samad told Reuters at the scene.
Neighbours said they had awoken to crackling gunfire from American soldiers, who they described as laughing and drunk.
"They were all drunk and shooting all over the place," said Agha Lala, who visited one of the homes where killings took place. "Their (the victims') bodies were riddled with bullets."
A senior U.S. defence official in Washington rejected witness accounts that several apparently drunk soldiers were involved. "Based on the preliminary information we have this account is flatly wrong," the official said. "We believe one U.S. service member acted alone, not a group of U.S. soldiers."
Defense Secretary Leon Panetta called Karzai to offer his condolences. "I condemn such violence and am shocked and saddened that a U.S. service member is alleged to be involved, clearly acting outside his chain of command," Panetta said in a statement. "A full investigation is already under way."
The Afghan Taliban said in a statement emailed to media that it would take revenge for the deaths.
The U.S. Embassy in Kabul also said an investigation was underway and that "the individual or individuals responsible for this act will be identified and brought to justice".
ISAF Commander General John Allen promised a rapid investigation.
Civilian casualties have been a major source of friction between Karzai's Western-backed government and NATO-led forces in Afghanistan. NATO is preparing to hand over all security responsibilities to Afghans and all foreign combat troops are scheduled to leave by the end of 2014.
NATO Secretary General Anders Fogh Rasmussen said the alliance remained firmly committed to its mission and said anyone responsible would be held accountable.
The Koran burning and the violence that followed, including a spate of deadly attacks against U.S. soldiers, underscored the challenges the West faces as it prepares to withdraw.
Sunday's attack may harden a growing consensus in Washington that despite a troop surge, a war bill exceeding $500 billion over 10-1/2 years and almost 2,000 U.S. lives lost, prospects are dimming for what can be accomplished in Afghanistan.
"These killings only serve to reinforce the mindset that the whole war is broken and that there's little we can do about it beyond trying to cut our losses and leave," said Joshua Foust, a security expert with the American Security Project. (Additional reporting by Hamid Shalizi in Kabul, and Missy Ryan and Alister Bull in Washington; Writing by Amie Ferris-Rotman; Editing by Paul Tait and Michael Perry)