An appeals court in Mauritania has reduced a death sentence given to a blogger to a two-year jail term.
Mohamed Cheikh Ould Mohamed M’khaitir was convicted of blasphemy in 2014.
He will be set free as he has spent more than two years in jail. His lawyer called the news a “great victory”.
The blogger’s article was considered insulting to the Muslim Prophet Muhammad, although he said it was meant to criticise the use of religion to justify discrimination.
His blog was accused of questioning choices made by the Prophet Muhammad during holy wars in the 7th Century.
It also attacked the mistreatment of black Mauritanians who he argued were discriminated from birth.
The case, in the north-western city of Nouadhibou, has divided the country, an Islamic republic.
As the appeal opened on Wednesday, conservative Muslim protesters were demanding his execution by hanging.
But Alioune Tine from Human Rights group Amnesty International said his release was “a huge relief” because he had “been jailed for nearly four years simply for peacefully expressing his opinions”.
His lawyer Fatimata Mbaye told the AFP news agency that: “The law has been pronounced and religion has been respected”.