Aaron Yoon, the 24-year-old Canadian who has been held in a Mauritanian prison since December 2011 on terror-related charges, has been released.

Yoon was sentenced to two years in prison last July after being convicted of having ties to an al-Qaeda-affiliated terrorist group that operates in the North African region and of posing a danger to Mauritanian national security.

A Mauritanian court decided earlier this month to release Yoon for time served, roughly 18 months, and rejected prosecutors' requests to have his sentence extended to 10 years.

The Korean-Canadian was released at dawn Tuesday and turned over to Mauritanian intelligence officials for questioning, CBC's Adrienne Arsenault reported. He is expected to be deported to Canada soon, travelling on a temporary passport he was given by authorities.

"He's now free," Arsenault said. "The plan, it seems, is to get him back to Canada in the next two days.

"He has said all along that he has wanted to come back to Canada."

Yoon's release was facilitated by Canadian diplomats in Morocco, Arsenault said.

Neither the RCMP nor the Canadian government have commented on Yoon's release, but Canadian security officials "might want to have a conversation" with him when he arrives in Canada, Arsenault said.

Travelled to region with attackers

Yoon was accused by Mauritanian authorities of having links to al-Qaeda in the Islamic Maghreb (AQIM), and it later emerged that he had travelled to North Africa with two fellow Canadians who were involved in an attack on an Algerian gas plant in January that ended with the deaths of 37 hostages and 29 attackers.

Yoon reportedly travelled to Morocco, which borders Algeria, with Ali Medlej and Xris Katsiroubas, who attended the same high school as Yoon in London, Ont. Medlej and Katsiroubas were among the dead attackers found at the Tigantourine gas facility near In Amenas, Algeria.

The plant was ambushed by an Islamist militant group headed by Moktar Belmoktar, a former commander of al-Qaeda in the Islamic Maghreb.

Yoon has said his sole purpose for travelling to the North African region was for religious study. Before he was arrested, he attended a religious school in Mauritania, reportedly with Americans and Europeans, where he studied the Qur'an. Yoon was raised a Catholic but converted to Islam a year before graduating from London South Collegiate Institute.

Tortured in prison

Yoon has insisted that he didn't know how Medlej and Katsiroubas became linked with militants. In interviews with members of Amnesty International and CBC's Arsenault he said he first heard of the gas plant attack while in prison.

"He said he was horrified at what had happened to his two friends from high school," Arsenault said. "From the very beginning, he has said, 'I am different from them; this is not me. I did not do this.' "

Yoon told Amnesty International representatives who visited him in prison that he was tortured and forced to give a false confession. The human rights group called his claims "certainly credible and completely consistent with the wider pattern that we've known to be the case for quite some time in Mauritania."

Yoon told Arsenault earlier this year that he had kept his arrest from his family and friends because he was embarrassed, and the news came as a shock to his relatives, who said they had no idea he was in prison when reached by the CBC in April of this year.