(CNN)A Nigerian teen who was convicted in the northwest of the country of blasphemy has had his sentence overturned, his lawyer said Friday.
The appellate division of the Kano State High Court set aside Omar Farouq's sentence on Thursday because he did not have legal representation at his first trial, his counsel Kola Alapinni told CNN.
A Sharia court in Kano State convicted Farouq in August last year and sentenced him to ten years in prison after he was accused of using foul language toward Allah in an argument with a friend.
He will be released Monday after being in captivity for over five months with no access to family or lawyers.
The Sharia court judgment which was nullified Thursday described him as a 17-year-old minor.
Alapinni said Farouq's mother had fled to a neighboring town after mobs descended on their home following his arrest.
"We now need to arrange safe passage for him. His life is in danger in Kano -- it will never be the same," said Alapinni.
The Auschwitz Memorial in Poland has offered to fundraise to pay for Farouq's education, saying in a tweet that "we are all part of one humanity."
In a separate judgment, the court also quashed 22-year-old music studio assistant Yahaya Sharif-Aminu's death penalty sentence for insulting the Prophet Mohammed.
He had not been allowed legal representation before or during his trial -- in contravention of Nigerian citizens' constitutional right to legal representation, said his lawyers.
He was convicted on August 10 for making "a blasphemous statement against Prophet Mohammed in a WhatsApp Group," the judgment document stated.
Blasphemy is an offense that carries the death sentence under Kano State's Sharia Penal Code.
The recording was shared widely, causing mass outrage in the highly conservative, majority Muslim state, according to various reports.
However, Sharif-Aminu's case was remitted back to the Sharia court for a retrial due to procedural irregularities, said Alapinni.
The lawyer told CNN his team will appeal the entirety of the decision.
"Both cases have similar facts and the same judge. Why is one defendant free and not the other?" he said.
Amnesty International's country director Osai Ojigho said she welcomed Farouq's release and that "he should not have been convicted in the first [place]."
"We reiterate our stance that Aminu Yahaya Shariff should be given a fair hearing," she added.
The US Commission on International Religious Freedom reacted to the news with relief.
"This is a step in the right direction," said the federal government body's commissioner Frederick A. Davie in a statement. " It would be better if Sharif-Aminu were not retried at all... Ultimately, blasphemy convictions fly in the face of religious freedom norms and values."
Kano's State Governor, Abdullahi Ganduje, told clerics in Kano in August that he would sign Sharif-Aminu's death warrant as soon as the singer had exhausted the appeals process, according to local media reports.
Kano State, like most predominantly Muslim states in Nigeria, practices Sharia law alongside secular law.
In the eyes of many Nigerians, the adoption of Sharia law is a violation of the country's constitution, because they believe Article 10 guarantees religious freedom.
"This issue of blasphemy is incompatible with the Nigerian constitution," Leo Igwe, chair of the board of trustees for the Humanist Association of Nigeria, told CNN in September.
The court upheld the legality of the Sharia Penal system in both cases, a decision which Alapinni said he will also appeal in the Federal Court.
"It goes to the very root of religious freedom in Nigeria," he added.