Cheikh Ould Mohamed Ould Mkheitir came to world prominence when he was sentenced to death in December 2014 for blasphemy.
He then repented, and an appeal court in November 2017 downgraded the sentence to a two-year jail term.
His lawyers say he should have been released immediately, having spent four years behind bars, but he is still in custody.
Speaking at a press conference late Thursday ahead of presidential elections, Abdel Aziz defended Mkheitir’s continued detention, saying it was justified by “his personal security as well as the country’s.”
“We know that from the point of the view of the law, he should be freed, but for security reasons, we cannot place the life of more than 4 million Mauritanians at risk,” he said.
“Millions of Mauritanians took to the streets to demand his execution. His release would mean that chaos would be allowed to take root in the country,” he added.
Mkheitir’s lawyer, Fatimata Mbaye, told AFP that the president’s comments were “shocking.”
Her client, she said, was being held in “arbitrary detention. … This young man is not being held in a place known to the judicial system.”
Abdel Aziz is scheduled to step down after presidential elections, whose first round is taking place Saturday.
He came to power after a military coup, was elected in 2009 and again 2014, and cannot serve beyond a two-term limit.
In an open letter published Friday, a group of 10 rights groups, including the media watchdog Reporters Sans Frontieres (Reporters without Borders, RSF), called on Abdel Aziz to use his final weeks in office to end the “illegal detention.”
Failing to resolve this problem would greatly overshadow his legacy, they said.
Mkheitir, believed to be in his mid-30s, was accused of challenging decisions taken by the Prophet and his companions during holy wars in the seventh century.
In April, Justice Minister Dia Moctar Malal told the National Assembly that Mkheitir was in “temporary detention” and that “only the Supreme Court can rule on his fate.”
The case surrounding Mkheitir, also spelt Mkhaitir, unleashed fierce passions in the conservative Muslim state.
The appeal court decision triggered angry protests, prompting the government in April 2018 to harden religious laws so that showing repentance for blasphemy and apostasy could no longer prevent the death penalty.
The law was approved despite an appeal by the African Union’s human rights body for the government to review the bill.
The Mkheitir case contributed to Mauritania falling 17 spots in RSF’s 2018 World Press Freedom Index, the biggest drop of any African nation.