The incident, in a village in western Bengkulu province, sparked a rare debate in Indonesia about sexual violence.
The maximum penalty would have been 15 years each, but the judge said he took into account the boys' youth.
The girl, Yuyun, went missing on 2 April on her way back from school.
Her body was found in undergrowth two days later by villagers, bruised, beaten and with her hands tied.
The case was not widely covered by Indonesian media until it was picked up by activists online several weeks later.
That led to protests in the capital, Jakarta, and prompted the Minister for Child Protection Yohana Yembise to call for rapists to face the death penalty.
Five men are also facing trial in connection with the case, and police say two more suspects are still on the run.
Seven boys below the age of 18 have been sentenced to 10 years in jail each in Indonesia for the gang rape and murder of a 14-year-old girl.