The massacre of 16 villagers by a U.S. soldier triggered angry calls from Afghans for an immediate American exit even as the Obama administration vowed that the shocking killings would not alter U.S. plans for the war.

Just days before Sunday's attack, Kabul and Washington had made significant progress in negotiations on a Strategic Partnership Agreement that would allow American advisers and special forces to stay in Afghanistan after most foreign combat troops leave at the end of 2014.

But securing a full deal may be far more difficult now after an Army staff sergeant walked off his base in the southern province of Kandahar in the middle of night and gunned down at least 16 villagers, mostly women and children.

This could delay the signing of the Strategic Partnership Agreement, an Afghan government official told Reuters.

The attack was the latest incident to ignite Afghan anger at the United States, coming on the heels of U.S. soldiers' burning of the Koran on a NATO base last month, and other incidents that have intensified America's perception problem in Afghanistan.

The soldier, who has not been identified, is now in U.S. custody in Kandahar, a congressional source said on condition of anonymity. After leaving the Belambai base, the soldier began shooting people in two nearby villages, the source said. Five Afghans were wounded in addition to those killed.

The motive for the shooting was not immediately clear. The soldier was part of the 2-3 Infantry, 3rd Stryker Brigade Combat Team, from the Lewis-McChord base in Washington state. After serving three tours in Iraq, he arrived in Afghanistan in December and has been at the Belambai base since February 1.

U.S. officials, who have rushed to distance the shootings from the efforts of the 90,000-strong U.S. force that over the past year has beaten the Taliban back from much of southern Afghanistan, say an investigation was under way but did not know when it would conclude.

The incident is another unwelcome challenge for the Obama administration's efforts to establish stability - which will require the support of ordinary Afghans - over 10 years after the Taliban government was toppled.

Obama and his NATO partners intend to pull most of their troops out of Afghanistan by the end of 2014, leaving an inexperienced local army in charge.

Officials in Washington denied suggestions the killings might alter U.S. plans.

I do not believe this incident will change the timetable of a strategy that was designed and is being implemented in a way to allow for the withdrawal of U.S. forces, to allow for their transfer of lead security authority over to the Afghans, White House spokesman Jay Carney told reporters.

Afghanistan's parliament condemned the killings, saying Afghans had run out of patience with the actions of foreign forces and the lack of oversight.

Civilian deaths have long been one of the main sources of tension between Kabul and Washington.

U.S. officials warned of possible reprisal attacks after the villagers were killed in the likely rogue shooting.

TALIBAN TO EXPLOIT KILLING?

Fury over the killing spree, which brought demands that the United States withdraw earlier than scheduled, could be exploited by the Taliban to gain new recruits.

We have benefited little from the foreign troops here but lost everything - our lives, dignity and our country to them, said Haji Najiq, a Kandahar shop owner.

The explanation or apologies will not bring back the dead. It is better for them to leave us alone and let us live in peace.

Anti-Americanism, which boiled over after copies of the Muslim holy book were inadvertently burned by U.S. soldiers, might deepen after the Kandahar carnage.

The Americans said they will leave in 2014. They should leave now so we can live in peace, said Mohammad Fahim, 19, a university student. Even if the Taliban return to power our elders can work things out with them. The Americans are disrespectful.

The civilian deaths may also force Afghan President Hamid Karzai to harden his stance in the partnership talks to appease a public already critical of his government's performance.

The partnership agreement, which Washington and Kabul have been discussing for more than a year, is expected to be a framework for U.S. involvement in Afghanistan after foreign combat troops leave at the end of 2014.

Without a pact that keeps U.S. advisers or special forces here, there is a danger that civil war could erupt again in Afghanistan; it's unlikely forces could keep insurgents at bay without outside help.

The Kandahar violence came just days after the United States and Afghanistan signed a deal on the gradual transfer of a major U.S.-run detention centre to Afghan authorities, overcoming one of the main sticking points in the partnership negotiations.

The Americans are not here to assist us they are here to kill us, said Najibullah, 33, a house painter in Kabul.

I hate the Americans and I hate anyone who loves them, so I hope there is no long-term partnership between our countries.

Afghanistan wants a timeline to take over detention centres and for the United States and NATO to agree to end night raids on Afghan homes as preconditions for signing the pact.

Pentagon spokesman George Little said U.S. strategy would continue as it had before Sunday's shooting.

There has been a series of troubling incidents recently, but no one should think that we are steering away from our partnership with the Afghan people, our partnership with Afghan National Security Forces, and our commitment to prosecute the war effort, he told reporters.

NIGHT-TIME MASSACRE

U.S. Secretary of State Hillary Clinton on Monday said she was shocked and saddened by what she called the inexplicable massacre of Afghan villagers.

But many Afghans have grown weary of American apologies. Such incidents are often quickly exploited by insurgents and the Afghan Taliban said it would take revenge.

Kandahar is the birthplace of the Taliban, who were toppled by U.S.-backed Afghan forces in late 2001. Southern and eastern provinces have seen some of the fiercest fighting of the war.

The Kandahar shootings will give the Taliban the chance to prove to Afghans that they are the freedom fighters and the Americans are the evil ones, said Waheed Mujhda of the Afghan Analysts Network.

Sunday's attack may also harden a growing consensus in Washington about what can - and can't - be accomplished in Afghanistan.

The bill for the war has already exceeded $500 billion and more than 1,900 U.S. troops have been killed, with the total number of foreign troops killed approaching 3,000.

Not only will this horrific incident enrage average Afghans, it will likely significantly impact the American public attitude toward the war and renew calls for speeding up the pace of U.S. troop withdrawals, said Lisa Curtis, a security expert at the Heritage Foundation.

Karzai, whose relationship with his Western backers is fraught at the best of times, condemned the rampage as intentional murders and demanded an explanation. Karzai's office released a statement quoting a villager as saying American soldiers woke my family up and shot them in the face.

There were conflicting accounts of how many U.S. soldiers were involved, with witness accounts saying there were several. Officials in Washington said only one soldier was involved.

Amnesty International warned that those behind such attacks must be brought to justice or it would risk reinforcing a perception among many Afghans - fuelled by the Taliban - that NATO had not done enough to keep Afghan civilians safe.

The United States must act swiftly and take the lead in an independent, credible, and transparent investigation provide adequate compensation to the families affected by the killings, said Sam Zarifi, Asia-Pacific Director at Amnesty International.

(Additional reporting by Hamid Shalizi and Mirwais Harooni in KABUL; Susan Cornwell, Missy Ryan, Alister Bull in WASHINGTON; Michelle Nicols, Louis Charbonneau and Emily Flitter in NEW YORK; Writing by Michael Georgy; Editing by Missy Ryan and Cynthia Osterman)