JOINT BASE LEWIS-McCHORD, Wash. — A soldier accused of killing Afghan civilians for sport was sentenced Wednesday to 24 years in prison after he pleaded guilty and agreed to testify against other defendants in the case.

Specialist Jeremy N. Morlock, one of five soldiers from an Army Stryker brigade based here who are accused of staging combat situations to kill three civilians in Afghanistan last year, told the military judge presiding over the case, Lt. Col. Kwasi L. Hawks, that the deaths were neither justified nor accidental.

“The plan was to kill people, sir,” Specialist Morlock told the judge at the start of a court-martial.

The sentence, plea and agreement to testify followed a deal Specialist Morlock and his lawyers negotiated with prosecutors in January. The military sentencing guidelines for the charges to which he pleaded guilty — including three counts of premeditated murder, conspiracy to commit murder and assault — recommend life in prison, with or without the possibility of parole. His lawyers say he could be eligible for parole in about seven years.