Militants in Afghanistan have launched an attack on a government delegation visiting the site where a US soldier killed 16 civilians.

Two of Afghan President Hamid Karzai's brothers and several top security officials were in the delegation in Panjwai in Kandahar province.

One Afghan soldier and three of the militants were killed, police said. The delegation is heading back to Kandahar.

The US soldier said to have carried out Sunday's attacks is under arrest.

A US military official said that "probable cause" had been found, meaning they could continue to hold the soldier. The unnamed 38-year-old staff sergeant is being held at an undisclosed location.

'No rush to exits'

A senior Afghan official confirmed to the BBC that an attack "from several directions" had taken place on the delegation, which was there to meet villagers and tribal elders. Afghan forces returned fire.

The BBC's Bilal Sarwary in Kabul says officials reported a 10-minute gun battle during which Taliban fighters fired from a distance at a mosque where the delegation and civilians were taking part in a prayer service.

Analysis President Karzai is personally involved in Kandahar - it is his home province and he has close relations with tribal elders. He, his friends and his brothers have all been working around the clock to say the soldier will be brought to justice and that taking to the streets in violent protest is not in the interests of the Afghan people or the Afghan government. Afghanistan will push for a US trial of the soldier which one aide said should be "in open court, in the presence of the media in weeks or months, but not years". If guilty, Kabul would demand the death penalty. It also wants those in charge at the base to be held responsible for not preventing the soldier's attack. On the issue of Nato, senior members of the Afghan government say any premature withdrawal will undermine the entire mission and the only people to benefit would be the Taliban.

Panjwai police said that in addition to the soldier killed, two other people, including an intelligence officer, were wounded.

One of Mr Karzai's brothers, Qayum, told the Associated Press news agency it appeared initially that the attack was not serious and the delegation "assumed that it was the national army that started to fire in the air".

He said the delegation, which included Kandahar's governor and the minister of border and tribal affairs, was safe and returning to Kandahar city.

A member of the delegation, Abdul Rahim Ayubi, told AP the governor was trying to explain to locals that the shooting was an isolated incident.

"But the people were just shouting and they were very angry. They didn't listen to the governor. They accused him of defending the Americans instead of defending the Kandahari people," Mr Ayubi said.

Anti-US sentiment is already high in Afghanistan after soldiers burned some copies of the Koran at a Nato base in Kabul last month, sparking deadly riots across the country.

On Tuesday morning, some 600 students took part in a rally in the eastern city of Jalalabad, condemning the Kandahar attack and chanting "Death to America! Death to Obama!".

In Washington, US President Barack Obama said America was "heartbroken over the loss of innocent life", and promised no effort would be spared in investigating the shooting and bringing the culprit to justice.

"We will follow the facts wherever they lead us," he said, "and we will make sure that anybody who was involved is held fully accountable with the full force of law."

He also insisted that the US will "responsibly" withdraw its forces between now and the end of 2014, the date he set with allies to close out the war, dismissing media speculation that he might speed up the process.

US Defence Secretary Leon Panetta said the soldier who has been detained in connection with the Kandahar shootings could face the death penalty if found guilty.

The Taliban has renewed threats of revenge attacks, saying it would behead "sadistic" American soldiers.

'Cowered in fear'

Details about Sunday's shootings are still unclear. The American soldier left his base in Kandahar in the early hours and went on a rampage in nearby villages.

Previous tension points February 2012: Deadly protests after US troops inadvertently burn Koran

Deadly protests after US troops inadvertently burn Koran January 2012: Video shows US marines urinating on dead Afghans

Video shows US marines urinating on dead Afghans March 2011: Radical US pastor burns Koran, triggering deadly protests

Radical US pastor burns Koran, triggering deadly protests April 2008:Protests against cartoon of Prophet Muhammad in Danish newspapers

Locals told reporters how they cowered in fear as the man made his way from door to door, trying to get into their houses.

"I saw a man, he dragged a woman by her hair and banged her head repeatedly against the wall. She didn't say a word," one witness said.

He broke into three houses and killed 16 people, most of them women and children. He then burned their bodies, according to reports.

The US defence secretary said the soldier "came back to the forward operating base and basically turned himself in, told individuals what had happened".

Pentagon officials said they would not release his name while the investigation was going on.

Reports said the soldier, who has three children, had been deployed to Afghanistan in December for his first tour of duty there after serving three times in Iraq.