The military will charge Army Staff Sgt. Robert Bales with 17 counts of murder stemming from a massacre of Afghan villagers, a U.S. official said Thursday.

Bales, 38, will be formally charged Friday, the official said. He has been detained at a maximum-security military prison at Fort Leavenworth, Kan., for the past week.

The killings are considered the worst U.S. atrocity of the Afghan war and have roiled relations between the United States and Afghanistan at a time when American commanders are seeking to stabilize the country in preparation for an eventual U.S. exit. President Obama has promised to hold accountable “anyone responsible” for the killings.

The murder charges indicate that Army prosecutors have concluded that the slayings were premeditated and that Bales was fully aware of his actions, but Bales’s civilian attorney has said that his client does not remember much about what happened in the pre-dawn hours of March 11. Military officials have said Bales walked off a small combat outpost in Kandahar province and killed 17 villagers, most of them women and children, and later walked back to his base and turned himself in.

Authorities had previously said 16 Afghans were killed and several others critically wounded. They said the death toll has since risen to 17.

Although Afghan President Hamid Karzai relies on the U.S. and NATO military coalition to hold the Taliban-led insurgency at bay, he referred to foreign troops as “demons” after the massacre. He also demanded that they withdraw from villages across the country, which would upend the U.S. military’s counterinsurgency strategy.

Bales will also be charged with six counts of attempted murder and aggravated assault in the woundings of six other villagers, as well as dereliction of duty, said the U.S. official, speaking on the condition of anonymity because the charges were not yet filed. Bales’s attorney, John Henry Browne of Seattle, could not be reached for comment.

The attacks came at a time of evaporating trust between the U.S. military and its Afghan allies.

In January, an Internet video depicted U.S. Marines urinating on the corpses of Taliban fighters. Soon after, American troops burned copies of the Koran and other holy texts, an apparently inadvertent act that sparked widespread riots.

Meanwhile, Afghan soldiers and others have stepped up treacherous attacks on U.S. troops, including the slaying of two U.S. officers assigned to the high-
security Afghan Interior Ministry. Last week, an Afghan interpreter working for NATO hijacked a truck, immolated himself and tried to run down a crowd of high-ranking Marines waiting to greet Defense Secretary Leon E. Panetta as his plane landed in Helmand province.

Military officials so far have not offered a motive for the Kandahar killings, but they have said they are investigating whether Bales was drinking on the night of the attacks.

Bales was involved in at least three separate incidents in which alcohol appears to have been a factor.

According to a 2002 Tacoma, Wash., police report, Bales was charged with assault in a fracas at a casino. He allegedly punched a security guard in the chest when two bouncers tried to evict him after another customer said he had made a threat. The guards described him to police as intoxicated.

In 2008, Bales struck a traffic sign and a tree when he rolled over his red Mustang on a road near his house in the Tacoma area. Witnesses said he was bleeding profusely and smelled of alcohol when he fled into some woods. He called police more than 10 hours later and said he had fallen asleep at the wheel, but no blood test was done to determine whether he had been drinking. Court records show that he was fined $792.50 for hit-and-run and property damage.

The Associated Press reported that in 2008 Bales was accused of shaking hands with a woman and pulling her hand to his crotch, then punching and kicking her boyfriend. He was described as “extremely intoxicated.” Pierce County, Wash., sheriffs deputies referred the case to prosecutors, but no charges were brought.

Morello reported from Tacoma. Staff writer Mary Pat Flaherty contributed to this report.