A Peruvian court on Thursday sentenced former army officers and soldiers to prison for killing dozens of peasants in an Andean village 31 years ago during the height of a conflict between the government and Shining Path rebels.

In the 1985 massacre in the town of Accomarca, 71 villagers were killed, including 23 children.

Soldiers stormed the town in search of subversive material but found no ammunition, explosives or Shining Path propaganda, according to a truth commission established by Peru.

Troops led by an officer, Telmo Hurtado, then separated men from a group of women and children, and then shot them and set them on fire. Mr. Hurtado has admitted to taking part in the massacre but has said that he was following orders.

The court sentenced Mr. Hurtado to 23 years in prison. He was arrested in the United States on immigration violations in 2007 and extradited to Peru to face charges related to the massacre in 2011.

Four other officials were sentenced to at least 24 years in prsion, and several soldiers face sentences of 10 years. Only Mr. Hurtado is currently in custody.

Peru’s truth commission estimated that about 69,000 people died or went missing in the two decades of the conflict with the Shining Path rebels. The commission blamed the rebel group for most of the killings and state authorities for about a third.

Small bands of rebels still operate in remote regions of Peru and have close ties to drug traffickers.