The declaration, which surprised the volatile African country and which has significant political implications, came in a letter, dated March 18, sent to the 12 states which have introduced Islamic law.
It is expected to cause considerable unease in northern Nigeria where the mainly Muslim population generally supports the system, known as the Sharia but delighted Christian leaders opposed to the code.
In the letter, the country's Justice Minister Kanu Agabi said the application of the Sharia violates Nigeria's constitutional commitments to respect human rights and not to discriminate on grounds of religion or sex because it applies only to Muslims, and in some cases, only to women.
"As attorney-general, it is my duty to ensure that our laws are applied in accordance with the constitution," the minister said on Thursday, explaining his letter.
"Any law that is applied only to people on the basis that they are Muslims, or only to people on the basis of their sex, is discriminatory. The constitution prohibits this. I am not the one prohibiting, it is Nigeria's constitution that prohibits it," he said.
Although he did not specifically mention the case, much attention has been focussed in Nigeria and abroad in past months on the sentencing to death-by-stoning of a 35-year-old Nigerian woman, Safiya Husaini, found guilty last October of adultery.
A judgment in an appeal of the case against Safiya Husaini is due to be given on Monday.
"The fact that Sharia law applies only to Muslims or to those who elect to be bound by it, makes it imperative that the rights of such persons to equality with other citizens under the constitution should not be infringed," Agabi said in his letter, a copy of which was published in the newspapers.
Embarrassment to Obasanjo
He argued that a Muslim should not be given a different punishment than one imposed on other Nigerians for a similar offence.
The minister called on the states implementing Sharia law to amend their legislation, removing the aspects relating to criminal law and punishments.
"I appeal to you, therefore, to take steps to secure modification of all criminal laws of your state so that the courts will not be obliged to impose punishments which derogate from the rights of Muslims under the constitution," he said in his letter.
The statement by Agabi is the first unequivocal statement by the government of President Olusegun Obasanjo that the criminal aspects of the Islamic law violate the constitution.
In February 2001, a month after the legal system was first introduced in one state, Obasanjo said he believed the declaration of Islamic law was primarily a political act and would "fizzle out".
It has not done so and this has caused embarrassment to Obasanjo.
Nevertheless, the introduction of the Islamic legal system has had wide support in the mainly Muslim north.
"Muslims are going to be hurt by the declaration. The government simply wants to destroy the Sharia. Muslims will not tolerate it. It is religious persecution and we will react," said prominent Muslim scholar Ahmad Murtala.
Northern states to continue implementing Sharia
"We warn the government that peace and cohesion in Nigeria depend on Muslims being allowed to practise their religion as ordained by God," he added.
In an interview with the Hausa language service of the BBC, Ahmed Sani, the governor of Zamfara State, insisted that Sharia courts were legal under the constitution.
The northern governors had no intention of taking the matter to the Supreme Court to resolve it but would write back to the justice minister to explain their intention to continue implementing Sharia, he said.
In response, the minister declined to say what the government would do if the 12 states implementing Sharia reject his appeal to amend their legislation, suggesting court action could only take place over a specific case, and not simply to determine a point of principle.
"It is not possible for the federal government to go to the Supreme Court on this issue, as a theoretical issue. To go to the Supreme Court it needs to be a specific case, a practical case, that is taken, for the Supreme Court to decide," he said. - Sapa-AFP