A US soldier who pleaded guilty to the murders of three Afghan civilians has been sentenced to 24 years in prison after saying "the plan was to kill people" in a conspiracy with four fellow soldiers.

The military judge said he initially intended to sentence Jeremy Morlock to life in prison with possibility of parole but was bound by the plea deal.

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, his attorney, Frank Spinner, said. He will be dishonourably discharged as part of his sentence.

The 22-year-old is a key figure in a war crimes investigation that has raised some of the most serious criminal allegations to come out of 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 came hours after he pleaded guilty on Wednesday to three counts of murder, and one count each of conspiracy, obstructing justice and illegal drug use at his court martial at the Lewis-McChord military base in Washington state.

Under his plea deal, he has agreed to testify against his codefendants.

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 after the sentencing, Spinner read a statement prepared by Morlock in which the soldier apologised for the pain he had caused his victims' families and the people of Afghanistan and asked for forgiveness from his fellow soldiers.

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.

Morlock said he had second thoughts about the murder plot while home on leave in March 2010, after the first two killings.

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

Morlock said he did not 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.

Morlock, his voice shaking at times, told the judge he had asked 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 believed 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.