The decision came after three days of wrenching testimony that painted a moment-by-moment, bullet-by-bullet account of one of the worst atrocities of the United States' long war in Afghanistan.

The six-member military jury considering Sergeant Bales's fate had two options: sentence him to life in prison with no possibility of parole, or allow him a chance at freedom after about 20 years behind bars. His guilty plea in June removed the death penalty from the table.

In pressing for mercy, the defense team said Sergeant Bales had been a good soldier, a loving father and a stand-up friend before snapping after four combat deployments to Iraq and Afghanistan. But prosecutors said he was a man frustrated with his career and family, easy to anger, whose rage erupted at the end of his M-4 rifle.

"He liked murder," a prosecutor, Lt. Col. Jay Morse, said in closing arguments on Friday. "He liked the power it gave him."

In the end, the jury sided with that argument. It deliberated for about 90 minutes before returning to a courtroom packed with soldiers, relatives of Sergeant Bales, and nine Afghan men and boys who had testified earlier in the week about the harm Sergeant Bales had inflicted on them and their families.

As the sentence was read, an interpreter gave a thumbs-up sign to the Afghans. On the other side of the courtroom, Sergeant Bales's mother wept, holding her face in her hands. Sergeant Bales, 40, showed no reaction. He responded with polite "yes, sirs" to the judge's questions about his appellate rights, before being led away.

He will be dishonorably discharged.

Outside the court, the Afghan villagers told reporters that the sentence did little to ease their anger and loss. Many wanted Sergeant Bales to be executed, and said his crimes represented the barest fraction of the pain and death that Afghans have endured over the last decade.

The men tugged at the maroon pants of a boy named Sadiqullah, revealing a leg scarred and disfigured by bullet wounds.

"We came all the way to the U.S. to get justice," said Haji Mohammed Wazir, who lost 11 members of his family in the massacre. "We didn't get that."

The killings took place in the Taliban stronghold of Kandahar Province, in two villages that were little more than an assortment of mud-walled homes, with no electricity or running water, where residents cultivated wheat and other grains. On March 11, 2012, after a night of drinking and watching movies with other soldiers, Sergeant Bales slipped away from his combat outpost and set off toward the villages.

What happened next was brought into vivid detail by the testimony of the nine Afghan men and boys.

Wearing traditional Afghan shalwar kameez and turbans as they faced a wall of crew cuts and crisp blue military dress uniforms, the Afghans spoke in Pashto of this unknown American who burst into their lives like a camouflaged grim reaper. They recalled how he hit and kicked members of their family, gunned down defenseless old men, mothers and children, and set their bodies on fire.

Several American service members also testified to the massacre's outward ripples, describing how a wounded 7-year-old girl named Zardana had to be taught to walk and use the bathroom again, how Afghans seethed with outrage in the Panjwai district, and how the American military had to suspend operations in the area after the killings.

On Friday, prosecutors described Sergeant Bales as a "methodical killer," uncaring and unrepentant.

In a closing argument illuminated by graphic videos and photos of the dead and wounded, Colonel Morse said Sergeant Bales had shown no mercy to the Afghan families, and deserved none from his military peers.

"Sergeant Bales not only had no remorse, but knew everything he was doing," Colonel Morse said. "He decides to take out his aggression on the weak and the defenseless."

Even as Emma Scanlan, a lawyer for Sergeant Bales, asked jurors to grant him and his family "a sliver of light" with the possibility of parole, she did not provide an explanation for the murders. For months, his defense had suggested that post-traumatic stress or a brain injury had played a part, but it did not present any medical experts during the sentencing hearing. Even Sergeant Bales, speaking to jurors on Thursday, balked when trying to explain his actions.

All anyone could do was guess. In a letter read to jurors on Friday, a former supervisor of Sergeant Bales said that the heavy toll of combat tours, growing stress and personal problems seemed to reach a critical mass that night in Kandahar.

"I believe he was finally overwhelmed by witnessing the deaths and injuries of the soldiers he loved so much," the officer wrote. "The darkness that had been tugging at him for the last 10 years swallowed him whole."