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.

The 14-year-old was found dead on the banks of the River Leven in Dunbartonshire on 25 August 1996.
Her mother, Margaret McKeich, recently led appeals as the inquiry reached 20 years without the killer being found.
Crimestoppers said the reward would be paid for information which leads to an arrest and conviction.
Information passed directly to the police will not qualify for the reward.
Angela Parker, national manager for Crimestoppers in Scotland, said: "Twenty years on, and Caroline's family are still left with unanswered questions as to what happened to her.
"I am asking for people who might have any information, no matter how insignificant they think it might be, to contact Crimestoppers anonymously, because you could be the person that provides the missing pieces to the puzzle.
"We never ask who you are or any of your details. You'll never speak to anyone from the police or ever go to court. Please do the right thing, and tell us who is responsible for taking a young girl's life."
Anyone with information is asked to contact Crimestoppers on 0800 555 111 or through an anonymous online form.
Last week police said they were following up more than 20 calls after the murder inquiry featured on the BBC's Crimewatch programme.
Some calls related to the identity of a hooded man seen near Caroline before she died.
Video contributions to the programme were also made by Mrs McKeich and the schoolgirl's friend, Joanne Menzies, who was one of the last people to have seen her alive.
Police Scotland's Homicide Governance and Review team recently started a fresh investigation and forensic scientists are re-examining more than 300 items collected at the time of Caroline's death.

Some 66 Israelis - all but two of them soldiers - have also died in the mission to destroy rockets and tunnels used by the militant Islamist group Hamas.
What do we know about who died and where they were killed?
According to figures from the UN's Office for the Coordination of Humanitarian Affairs (OCHA), up to 6 August, 1,890 Palestinians had lost their lives in the conflict.
Note: Figures up to 6 August
Read more
Among the dead were 414 children and 87 men and women over the age of 60.
The youngest to be killed was 10 days old, while the oldest was 100.
While the UN puts the number of militant dead below 200, Israel claims about 900 Palestinian militants were killed in the fighting.
Palestinians were killed right across Gaza - a strip of land 40km (25 miles) long and 10km wide. The highest numbers lost their lives in Khan Younis, in the south of Gaza, and Gaza City in the north.
Many took refuge in shelters run by the United Nations, including schools. However, these UN schools also came under fire, including in North Gaza, Jabaliya and Rafah.
Meanwhile, two Israeli civilians were killed - one near Dimona and the other near the Erez border crossing into northern Gaza; and a Thai farm worker was killed in Netiv Haasara, which borders Gaza.
Produced by Christine Jeavans, Lucy Rodgers, Gerry Fletcher and Laura Cantadori
Correction 15 October: Locations of the deaths of civilians in Israel have been changed after being incorrectly reported in an earlier version.
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.
[NEXT_CONCEPT]
The Crimestoppers charity is offering a £10,000 reward for information about the 1996 murder of Scottish schoolgirl Caroline Glachan.
[NEXT_CONCEPT]
Almost 1,900 Palestinians, mostly civilians, have been killed since the launch of Israel's Operation Protective Edge at the beginning of July.