Updated

An American soldier will avoid the death penalty for killing 16 Afghan civilians during nighttime raids on two villages last year, after a military judge accepted his guilty pleas in the case Wednesday.

Staff Sgt. Robert Bales' pleaded guilty to multiple counts of murder at a hearing at Joint Base Lewis-McChord south of Seattle. He then described shooting each victim, saying there is "not a good reason in this world" for what he did.

The judge, Col. Jeffery Nance, later accepted Bales' pleas, meaning a jury will decide in August whether the soldier is sentenced to life with or without the possibility of parole.

Bales was charged in the March 2012 attacks on two villages near the remote base in southern Afghanistan where he was posted. Most of the victims were women and children, and some of the bodies were burned. Relatives have told The Associated Press they are irate at the notion Bales will escape execution for one of the worst atrocities of the Afghanistan war.

Prosecutors and defense lawyers considered the plea deal a win-win.

Military law experts had suggested that given Bales' prior deployments and apparent post-traumatic stress disorder, it was unlikely a jury would sentence him to death. And Bales' attorneys have sought to place blame with the military for sending him back to war in the first place. A long, drawn-out court proceeding also could have further inflamed tensions in Afghanistan.

In court Wednesday, Bales read from a statement in a clear and steady voice, describing his actions for each killing in the same terms.

Bales, 39, said he left his base and went to the nearby villages of mud-walled compounds. Once inside, he said he "formed the intent" of killing the victims, then shot each one.

"This act was without legal justification, sir," Bales told the judge while seated at a defense table, his handles folded in front of him.

Lt. Col. Jay Morse, one of the prosecutors, raised concerns during the hearing that the soldier's testimony contradicted what he earlier acknowledged in a signed "stipulation of facts" from that night.

Morse noted Bales testified that he made the decision to kill each victim when he raised his gun and pointed it at them. But in the stipulation, Bales said he struggled with one of the women before killing her, and that "after the tussle" he decided to "murder anyone that he saw."

The judge questioned Bales about it, and Bales confirmed that he had decided to kill everyone after struggling with the woman.

At one point, Nance asked Bales why he committed the slayings.

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

Nance also questioned Bales about the burned bodies. Bales said he remembered there being a kerosene lantern in one of the rooms, and he recalled there being a fire and having matches in his pocket when he returned to the base. But he said he didn't remember setting the bodies on fire.

Nance pressed him on whether he set the bodies on fire with the lantern, and Bales replied: "It's the only thing that makes sense, sir."`

Defense attorney Emma Scanlan earlier entered Bales' pleas on his behalf. She entered one not guilty plea, to a charge that he impeded the investigation by breaking his laptop after he was taken into custody. The Army ended up dropping that charge.

Although Wednesday's proceedings provided Bales' account for the first time, survivors who testified by video link from Afghanistan during a hearing last fall vividly recalled the carnage.

A young girl in a bright headscarf described hiding behind her father as he was shot to death. Boys told of hiding behind curtains as others scrambled and begged the soldier to spare them, yelling: "We are children! We are children!" A thick-bearded 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.

Prosecutors say that before dawn on March 11, 2012, Bales slipped away from Camp Belambay in Kandahar Province, armed with a 9 mm pistol and M-4 rifle outfitted with a grenade launcher.

He first attacked one village of mud-walled compounds, Alkozai, then returned to the base, woke up a fellow soldier and told him about it. The soldier didn't believe him and went back to sleep. Bales then left to attack a second village, Najiban.

The massacre prompted such angry protests that the U.S. temporarily halted combat operations in Afghanistan, and it was three weeks before Army investigators could reach the crime scene.

Bales was serving his fourth combat deployment and had an otherwise good if undistinguished military record in a decade-long career. The Ohio native 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.