Updated

A Mauritanian official says a 24-year-old Canadian man was sentenced to 18 months in prison after being convicted of having ties to al-Qaida's North African branch but he will be freed because he has already served his time.

Prosecutor Ahmed Ould Abdalla told the Associated Press late Sunday that the court decided to release Canadian national Aaron Yoon because he had already been imprisoned for the duration of his sentence. He was first arrested in December of 2011.

Yoon said he travelled to Mauritania to study the Quran. He reportedly travelled to the region with two other Canadians, who were later implicated in a separate terror attack on a BP-operated natural gas plant in southeastern Algeria earlier this year, which ended with the deaths of 37 hostages.