Mauritania has moved to strengthen a law criminalising apostasy and blasphemy, after a court in the West African nation ordered the release of a local blogger who faced the death penalty for allegedly criticising the Prophet Muhammad.

An amendment to Article 306 of the country's penal code will now see the death penalty applied to "every Muslim, man or woman, who ridicules or insults Allah", his messenger, his teachings, or any of his prophets, "even if [the accused] repents", according to state news agency AMI.

The change aims to "adapt procedures to new situations that were not previously taken into account" when the law was first passed in 1983, said Justice Minister Brahim Ould Daddah.

Officially an "Islamic republic", Mauritania's legal system is based on a mix of French civil law and Islamic law. Previously, any person found guilty of apostasy under Article 306 faced the death penalty if he or she did not repent.

Someone charged with apostasy who showed remorse could be sentenced to up to two years in prison and a fine.

Blogger released

The change comes after a court in Nouadhibou, a town on Mauritania's northwest coast, ordered the release of blogger Mohamed Cheikh Ould Mkhaitir, who was sentenced to death for apostasy earlier this month.

Mkhaitir was arrested in January 2014 in relation to an online post in which he argued that some people in Mauritania justify discrimination on the basis of religion.

A Mauritanian court charged and convicted him of apostasy for allegedly "speaking lightly" of the Prophet Muhammad, and handed down a death sentence.

Mkhaitir repented before the courts, saying he never intended to disparage the prophet.

Mkhaitir spent several years behind bars as the case navigated the Mauritanian court system.

On November 9, an appeals court in Nouadhibou re-sentenced him to two years imprisonment and a fine of about $170.

'Day of triumph'

The ruling was welcomed as "a great victory for Mauritanian justice", according to his lawyer, Mohamed Ould Moine. "The judges respected Mauritanian law, taking into account his regrets and repentance," he told Reuters after the hearing.

Alioune Tine, Amnesty International's West and Central Africa director, said the decision marked "a day of triumph for [Mkhaitir] and his family, as well as all those who campaigned on his behalf since 2014".

But Mauritanian prosecutors appealed the decision to release him and have called for the death penalty to be issued again, the Reuters news agency reported.

Thousands of people protested in the capital, Nouakchott, and other cities during the trial, demanding Mkhaitir be put to death, Reuters reported.

Mauritania has not carried out a death sentence since 1987.