The case of Mubarak Bala highlighted the complex issue of blasphemy in predominantly Muslim northern Nigeria where Sharia law runs alongside common law and criticism of Islam is highly sensitive.
Bala, who heads a Nigerian humanist association, was given a 24-year sentence by a high court in Kano State in April 2022 for online posts he wrote over several months in 2020 disparaging Islam, the Prophet Mohammed and God, according to court proceedings seen by AFP.
Bala, arrested in his home in neighbouring Kaduna and detained in Kano, pleaded guilty to all 18 charges brought against him at the high court despite attempts by the judge and his lawyer to make him change his plea.
His lawyer criticised the judgement as "outrageous" at the time and said they would appeal if Bala gave his approval.
In an online judgement released on Monday, an appellate court reduced the 24-year sentence to five, Mohammed Buba, one of Bala's defence counsels, told AFP.
"The court of appeal in a judgement it delivered yesterday (Monday) via Google Teams commuted the 24-year sentence handed down to Mubarak Bala," Buba said.
"This means Mubarak will serve only five years in prison and will then be free."
The defence team were still awaiting a copy of the judgement from the court to examine details of the judgement and determine when Bala would be expected to complete his sentence, Buba said.
"Details are still sketchy, we need to have the copy of the judgement before we say much."
Bala, who is from a religious Muslim home in Kano, renounced Islam and publicly declared himself an atheist, making passionate online posts about his humanist ideas and scathing attacks on Islam that were deemed blasphemous by many Muslims.
Blasphemy normally draws the death penalty under Sharia law, though it is rarely carried out in Nigeria, Africa's most populous state, where the north is predominantly Muslim and the south mostly Christian.
In some cases of alleged blasphemy in Nigeria, the accused are killed by mobs without going through the legal process.
At least two Muslim clerics and a singer have been sentenced to death for blasphemy in recent years although none has been executed. All three have appealed their sentences.