A Swedish appeals court has overturned an Afghan migrant’s conviction for child rape, ruling that he did not know the girl’s real age despite inputting it when ordering her a bus ticket.

The Afghan man, who is in his 20s, was convicted of raping a 13-year-old girl earlier this year and sentenced to one-and-a-half years in prison, a fine, and deportation.

A ruling by the Göta Court of Appeal has completely overturned the sentence and ordered the migrant be set free. The court said that it had not been proven that he did not know the actual age of the girl, Nyheter Idag reports.

According to court records, the Afghan met the child on social media and arranged to meet her in person, buying her a bus ticket. The minor later came to the man’s residence and the pair had sex, but she later reported the Afghan for rape.

The migrant claimed he did not know the girl’s age, but she testified in court that she had repeatedly told the migrant how old she was.

When ordering the bus ticket, the migrant put down her real age but later claimed he did so to get a discount — and that it was merely a coincidence he wrote 13.

The appeals court acquitted the migrant as the girl was shown to have previously lied about her age to a different male. She was therefore deemed not a reliable or credible witness.

There have been numerous cases of Afghan migrants in Sweden involved in rape attacks in the last several years. In one case in 2018, a pair of 18-year-old migrants raped a 40-year-old woman who had previously campaigned against the deportation of Afghan migrants from Sweden.

Follow Chris Tomlinson on Twitter at @TomlinsonCJ or email at ctomlinson(at)breitbart.com