The U.S. soldier accused of killing 16 Afghan civilians, many of them women and children who were asleep in their villages, pleaded guilty to murder and acknowledged that there was "not a good reason in this world" for his actions.

Robert Bales' plea Wednesday ensures that he will avoid the death penalty for the nighttime slayings that so inflamed tensions with Afghans that the U.S. military briefly suspended combat operations there.

Prosecutors say Bales slipped away before dawn on March 11, 2012, from his base in Kandahar Province. Armed with a 9 mm pistol and an M-4 rifle equipped with a grenade launcher, he attacked a village of mud-walled compounds called Alkozai, then returned and woke up a fellow soldier to tell him about it.

The soldier didn't believe Bales and went back to sleep. Bales then left to attack a second village known as Najiban.

Relatives of the dead were outraged at the idea that Bales could escape execution when they spoke to The Associated Press in April.

"A prison sentence doesn't mean anything," said Said Jan, whose wife and three other relatives were killed. "I know we have no power now. But I will become stronger, and if he does not hang, I will have my revenge."

A jury will decide in August whether Bales is sentenced to life with or without the possibility of parole.

Wednesday's proceedings marked the first time the 39-year-old Bales provided a public account of the massacre.

At one point, the judge asked Bales why he killed the villagers.

"I've asked that question a million times since then," Bales replied. "There's not a good reason in this world for why I did the horrible things I did."

Bales said he decided to kill everyone after struggling with one of the women.

Survivors who testified by video link from Afghanistan during a hearing last year vividly recalled the carnage.

A young girl described hiding behind her father as he was shot to death. Boys told of hiding behind curtains as others begged the soldier to spare them, yelling, "We are children! We are children!" A man told of being shot in the neck by a gunman "as close as this bottle," gesturing to a water bottle on a table in front of him.

The deaths raised questions about the frequency of combat deployments and post-traumatic stress disorder. Bales was serving his fourth deployment. Until the attacks, he had a good, if undistinguished, military record in a decade-long career. He suffered from PTSD and a traumatic brain injury, his lawyers say, and he had been drinking contraband alcohol and snorting Valium — both provided by other soldiers — the night of the killings.

Bales said he was also taking three doses of steroids each week to make himself "smaller, leaner, more fit for the mission," and to help him recover quickly after rigorous activity.

The drugs "definitely increased my irritability and anger," he said.

Given Bales' prior deployments and apparent PTSD, military law experts have suggested that a jury is unlikely to sentence him to death. Defense attorney John Henry Browne had sought to place blame with the military for sending Bales back to war.