The teens, aged 16-17, forced the younger boy into a wooded area in the Gottsunda district of Uppsala in October last year and then gang-raped and beat him at knife-point.
In December, Uppsala District Court sentenced four of them to one year and three months in a closed facility for juvenile offenders, and the fifth one, aged 16, to one year and one month.
However, it refused the prosecutor's request to also send them back to Afghanistan after they had served their punishment, given their age and the security situation in the country.
The latter point was then also brought before the appeals court, which threw it out on Wednesday, ordering their deportation and banning them from returning to Sweden for ten years.
“Several factors come into play when you consider deportation. First, it's a question of the seriousness of the crime. It's often said that if the offence carries a penalty of more than one year it may be grounds for deportation. In this case, the crime was far more serious,” the president of the Svea Appeals Court, Fredrik Wersäll, told the TT news agency.
The second factor is the person's ties to Sweden.
“In this case the court of appeals notes that the boys do not have a link to Sweden. Then you also try the issue whether it's possible to execute a deportation order. In this case the appeals court does not have its own expertise, but relies to a significant extent on the Migration Agency's opinions,” added Wersäll.
The court also ruled that the teenagers should be treated as adults and that hence any humanitarian reasons not to send them back were not strong enough to prevent deportation.
The boys all came to Sweden as refugees unaccompanied by any adults, and Wersäll said that the judges had very few previous court cases to rely on as guidance or precedence.
“It's simply because the phenomenon of unaccompanied refugee children is not something that has been around very long. New issues arise in a refugee situation like this. It is not particularly strange then that courts reach somewhat different conclusions,” he told TT.