The lone American soldier suspected in the apparently unprovoked slaughter of more than a dozen Afghan civilians Sunday confessed to the crime when he returned to his base that night saying, "I did it," defense officials told ABC News.

According to the officials, the 38-year-old Army staff sergeant, who has not been identified, returned to his base in Kandahar where he was disarmed after allegedly murdering 16 civilians – including nine children and three women -- in nearby villages. Back at the base, he described the massacre to officials there, the officials said.

"He went out in the early morning and went to these homes and fired on these families and then some time after that, came back to the forward operating base and basically turned himself in and told individuals what happened," Panetta told reporters.

The soldier has since retained a lawyer and is refusing to speak with investigators about what motivated him to allegedly gun down the civilians. Officials told ABC News the alleged shooter had been having marital problems since returning from deployment in Iraq in 2010 before he was sent to Afghanistan.

Investigators are also looking at the possibility that alcohol may have played a role in the incident, defense officials said, as alcohol was found near where he lived on base in Afghanistan.

An Afghan government delegation visiting one of the sites the shooting took place came under fire today. A member of the group's security team died during the attack, according to The Associated Press, but it's unclear whether anyone was injured.

The group was inside a mosque offering their condolences and prayers when they heard small and heavy arms fire.

The delegation includes two brothers of Afghan President Hamid Karzai, senior officials from Kabul and at least a dozen journalists.

Security forces traveling with the group responded, exchanging fire with the militants for about 10 minutes.

"We were giving them our condolences, then we heard two very, very light shots," Qayum Karzai, Hamid Karzai's brother, told the AP. "Then we assumed that it was the national army that started to fire in the air."

The attack comes as the Taliban vowed to take revenge against "sick-minded American savages" after the mass killing Sunday.

Student Protests in Afghanistan

In another sign of rising anger over the murders, several hundred students held a demonstration in Jalalabad.

A local eyewitness said the students were shouting that they won't tolerate the crimes of the U.S. forces in Afghanistan and that the Afghan government shouldn't sign the long-term strategic partnership with the United States.

Some protesters reportedly burned an effigy of President Obama, the AP reported.

Although the protest ended peacefully, it was the first major protest outside the area where the massacre occurred.

The alleged shooter has been identified as a 38-year-old Army staff sergeant based at Fort Lewis in Washington state. His name has not been released.

ABC News has learned that the soldier suffered a mild traumatic brain injury in 2010 while on deployment in Iraq.

It is unclear if the injury could have played a role in Sunday's massacre.

Officials said he went through the advanced TBI treatment at Fort Lewis and was deemed to be fine.