Five Afghan teenagers convicted of raping an Afghan minor should be deported after serving their sentences, a Swedish appellate court ruled Wednesday, overturning a lower court's decision.

All five defendants and the victim were unaccompanied minors who had applied for asylum in Sweden.

The prosecution had appealed the lower court's December decision that opposed the deportation.

The Svea Court of Appeal said the security situation in Afghanistan was not an impediment to the deportation.

Although the crimes were "serious," the five could be allowed re-entry to Sweden after 10 years, the court added, citing their youth.

Four of the five teens each received one year and three months in juvenile detention. A fifth defendant, aged 16, was given a 13-month sentence.

They were convicted of forcing the victim, who was under age 15, into a forested area on the outskirts of Uppsala, north of Stockholm, where they raped him at the end of October.

Part of the assault that included a beating was recorded on a mobile phone. The victim was also threatened with a knife. His identity was shielded by the court.

Prior to the assault the defendants had consumed alcohol and several said they were too drunk to remember the incident.

The motive was not clear.

Sweden in 2015 registered a record 163,000 asylum bids including 34,500 bids by unaccompanied minors; the majority of that category were Afghans.

The influx has sparked a debate about migration in the country, and Sweden has since introduced tighter border controls, signed a repatriation agreement with Kabul and has shifted its focus to integration.