JOINT BASE LEWIS-MCCHORD, Wash. — A U.S. soldier who pleaded guilty Wednesday to the murders of three Afghan civilians was sentenced to 24 years in prison after saying “the plan was to kill people” in a conspiracy with four fellow soldiers.

Military judge Lt. Col. Kwasi Hawks said he initially intended to sentence Spc. Jeremy Morlock, of Wasilla, Alaska, to life in prison with possibility of parole but was bound by the plea deal.

The 22-year-old Morlock is a key figure in a war crimes probe that has raised some of the most serious criminal allegations to come from the war in Afghanistan. Army investigators accused him of taking a lead role in the killings of three unarmed Afghan men in Kandahar province in January, February and May 2010.

His sentencing Wednesday came hours after he pleaded guilty to three counts of murder, and one count each of conspiracy, obstructing justice and illegal drug use at his court martial at Joint Base Lewis-McChord, south of Seattle.

Morlock, the first of five soldiers from the 5th Stryker Brigade to be court-martialed in the case, will receive 352 days off of his sentence for time served and could be eligible for parole in about seven years, said his lead attorney, Frank Spinner. He will be dishonorably discharged as part of his sentence.

Under his plea deal, he has agreed to testify against his co-defendants.

Asked by the judge whether the plan was to shoot at people to scare them, or to shoot to kill, Morlock replied, “The plan was to kill people.”

Speaking to reporters after the sentencing, Spinner read a statement prepared by Morlock in which the soldier apologized for the pain he had caused his victims’ families and the people of Afghanistan and asked for forgiveness from his fellow soldiers.

Spinner speculated that “morale problems and discipline problems” in Morlock’s brigade created an environment that contributed to the killings — an argument the defense presented in court through the testimony of sociologist and war crimes expert Stjepan Mestrovic.

Morlock had told investigators the murder plot was led by Staff Sgt. Calvin Gibbs of Billings, Mont., who is also charged in the case; Gibbs maintains the killings were legitimate.

Other witnesses, including Morlock’s mother and his former hockey coach, talked about the devastating effect of his father’s death in a boating accident in 2007. Morlock said he joined the Army hoping to follow in the footsteps of his father, a retired paratrooper.

But, ultimately, Morlock accepted that his actions were his and his alone, Spinner said.

Responding to criticism that 24 years was too light for three murders, Spinner pointed to Morlock’s willingness to take responsibility for his actions and testify against his co-defendants.

“He realized coming into court today the ‘why’s’ were not that important. He’s taking responsibility,” Spinner said.

The plea deal had been in place for nearly two months, so the sentence “wasn’t really a surprise” to Morlock, Spinner told reporters.

Morlock told the judge that he and the other soldiers first began plotting to murder unarmed Afghans in late 2009, several weeks before the first killing took place. To make the killings appear justified, the soldiers planned to plant weapons near the bodies of the victims, he said.

Army prosecutor Capt. Andre Leblanc characterized the crimes as acts of “unspeakable cruelty” by “a few extraordinarily misguided men.”

“We don’t do this. This is not how we’re trained. This is not the Army,” Leblanc said during his closing statement Wednesday.

During questioning by the judge Wednesday, Morlock said he had second thoughts about the murder plot while home on leave in March 2010, after the first two killings took place.

“It was really hard to come back,” he told Hawks, adding that he no longer wanted to “engage or be part of anything” like the killings that already had occurred.

Morlock said he didn’t voice his doubts to his fellow soldiers, however, and he went on to participate in the third killing in May.

Morlock also admitted to smoking hashish while stationed in Afghanistan, though he said he was not under the influence of the drug at the time of the killings. In addition, he admitted to being one of six soldiers who assaulted a fellow platoon member after that man reported the drug use going on in the platoon.

Morlock, his voice shaking at times, told the judge has had a lot of time to reflect on his actions in Afghanistan and ask himself “how I could become so insensitive and how I lost my moral compass.”

“I don’t know if I will ever be able to answer those questions,” he said, adding that he believes he “wasn’t fully prepared for the reality of war as it was being fought in Afghanistan.”

Earlier this week, the German news magazine Der Spiegel published three graphic photos showing Morlock and other soldiers posing with dead Afghans. One image features Morlock grinning as he lifts the head of a corpse by its hair.

After the January killing, platoon member Spc. Adam Winfield sent Facebook messages to his parents saying that his fellow soldiers had murdered a civilian and were planning to kill more. Winfield said his colleagues warned him not to tell anyone.

Winfield’s father alerted a staff sergeant at Lewis-McChord but no action was taken until May, when a witness in a drug investigation in the unit reported the deaths.

Winfield is accused of participating in the final murder. He admitted in a videotaped interview that he took part and said he feared the others might kill him if he didn’t.

Also charged in the murders are Pvt. 1st Class Andrew Holmes and Spc. Michael Wagnon II.

Seven other soldiers in the platoon were charged with lesser crimes, including assaulting the witness in the drug investigation, drug use, firing on unarmed farmers and stabbing a corpse.