What will explain to you what the steep path is? It is to free a slave, to feed at a time of hunger an orphaned relative or a poor person in distress, and to be one of those who believe and urge one another to steadfastness and compassion. Those who do this will be on the right-hand side, but those who disbelieve in Our revelations will be on the left-hand side, and the Fire will close in on them. Quran 90:12-20It is impossible to read Allah's guidance to the prophet without seeing his disdain for slavery. In 2:177 and 90:13 Allah makes it clear that he sees the freeing of slaves as a pre-requisite for earning his favor. Allah puts the freeing of slaves on the same plane as poverty eradication when he makes it one of the acceptable uses of required alms-giving (zakat):
Alms are meant only for the poor, the needy, those who administer them, those whose hearts need winning over, to free slaves and help those in debt, for God’s cause, and for travellers in need. This is ordained by God; God is all knowing and wise. Quran 9:60
Allah also makes the freeing of slaves a requirement for forgiveness throughout the Quran for a variety of events, such as the accidental killing of a Muslim, violation of an oath, or mistreating your wife:
Never should a believer kill another believer, except by mistake. If anyone kills a believer by mistake he must free one Muslim slave and pay compensation to the victim’s relatives, unless they charitably forgo it; if the victim belonged to a people at war with you but is a believer, then the compensation is only to free a believing slave; if he belonged to a people with whom you have a treaty, then compensation should be handed over to his relatives, and a believing slave set free. Quran 4:92
God does not take you [to task] for what is thoughtless in your oaths, only for your binding oaths: the atonement for breaking an oath is to feed ten poor people with food equivalent to what you would normally give your own families, or to clothe them, or to set free a slave—if a person cannot find the means, he should fast for three days. This is the atonement for breaking your oaths—keep your oaths. In this way God makes clear His revelations to you, so that you may be thankful. Quran 5:89
Those of you who say such a thing to their wives, then go back on what they have said, must free a slave before the couple may touch one another again—this is what you are commanded to do, and God is fully aware of what you do—Quran 58:3In the Quranic telling of the story of Moses and Pharaoh, Moses admits error in killing an Egyptian but counters that the Pharaoh enslaved the Children of Israel, insinuating that the enslavement is worse than murder:
Moses replied, ‘I was misguided when I did it and I fled from you in fear; later my Lord gave me wisdom and made me one of His messengers. And is this—that you have enslaved the Children of Israel—the favour with which you reproach me?' Quran 26:20-22Throughout the Quran, Allah provides goals and principles to Muslims, a specific path for the prophet to follow, and great flexibility to achieve them. With prayer, Allah established the requirement (2:3), then relented on the duration (73:20) and direction (2:144) during the prophet's lifetime. With commerce, Allah provided a mechanism for capturing contracts which he immediately gave extreme latitude around. With diet and fasting he set out rules and then provided generous exemptions. In the case of slavery, Allah not only made it clear that he wanted to see it eliminated (see above), but provided the prophet guidance to make it more humane, and harder to sustain during the prophet's lifetime. Allah orders generosity to slaves akin to parents, wives, and children here:
Worship God; join nothing with Him. Be good to your parents, to relatives, to orphans, to the needy, to neighbours near and far, to travellers in need, and to your slaves. God does not like arrogant, boastful people, who are miserly and order other people to be the same, hiding the bounty God has given them. We have prepared a humiliating torment for such ungrateful people. Quran 4:36-7Similar to wives, Allah allows Muslim men to incorporate female slaves into their harems:
[How] prosperous are the believers! Those who pray humbly, who shun idle talk, who pay the prescribed alms, who guard their chastity except with their spouses or their slaves—with these they are not to blame, but anyone who seeks more than this is exceeding the limits— who are faithful to their trusts and pledges and who keep up their prayers, will rightly be given Paradise as their own, there to remain. Quran 23:1-1Allah's goal isn't to turn slave-girls into sex-slaves, but to encourage marrying them (4:3). Allah categorically bans their usage as prostitutes:
Marry off the single among you and those of your male and female slaves who are fit [for marriage]. If they are poor, God will provide for them from His bounty: God’s bounty is infinite and He is all knowing. Those who are unable to marry should keep chaste until God gives them enough out of His bounty. Do not force your slave-girls into prostitution, when they themselves wish to remain honourable, in your quest for the short-term gains of this world, although, if they are forced, God will be forgiving and merciful to them. Quran 24:32Allah also forced the Muslims during the prophet's time to provide mechanisms for slaves to earn their freedom:
If any of your slaves wish to pay for their freedom, make a contract with them accordingly, if you know they have good in them, and give them some of the wealth God has given you. Quran 24:33So to summarize, Allah made his disdain of slavery known while commanding Muslims to free slaves. Understanding that Muslims already owned many slaves, Allah created rules forcing the humane treatment of slaves, while creating mechanisms to allow for their freedom through marriage or work contracts.
With all of that said, it is shocking that none of the medieval Muslim schools of thought (madhabs) pushed for the complete abolition of slavery. Ignoring 90:12-20, the madhabs viewed the verses calling for humane treatment of slaves as the beginning of a regulatory framework for keeping and trading slaves instead of a collection of temporary regulations to manage the freeing of slaves currently held. It is extremely distressing that Muslims, practicing under the auspices of the major madhabs, established the largest slave trading network in the world, enslaving 25 million people. Muslims have the sad distinction of being the last people on earth to condemn slavery, and only after receiving heavy pressure from the British. There were 450,000 slaves in Saudi Arabia (20% of the population) before their emancipation in 1962. The Islamic Republic of Mauritania did not criminalize slavery until 2007, where 20% of the population was enslaved.
The error of the madhabs can be attributed to a fundamental misunderstanding of the nature of the Quran. Rather than follow the Muʿtazilah teachings of the Abbasid Khalifas, which stressed that the Quran was created by Allah to guide the prophet, the madhab's followed the guidance of Ahmad ibn Hanbal, who believed that the Quran was an attribute of Allah himself, un-created, and eternal for all time. With that viewpoint, the temporary regulations meant to manage the elimination of slavery became permanent fixtures. Even when the madhab's began shifting their stances on slavery in the 19th century, they only did so citing the mistreatment of slaves, not the institution itself. Contemporary scholars like Sheikh Al-Munajjid attempt to defend 20th century Muslim slavery by citing its leniency relative to 19th century American slavery without condemning the practice itself. Salafi scholars like Saleh Al-Fawzan still call for the re-establishment of slavery.
I personally feel that most Muslim scholars completely mis-understand Allah's intent. Slavery is a trully abhorrent act which Allah repeatedly shows his disdain for. The fact that major scholars still defend Muslim slavery shows the inherent flaws of Ahmad ibn Hanbal's arguments for an eternal uncreated Quran. The early Caliph's were correct; the Quran was meant to be a guide for the Prophet during his time, not an eternal cementing of the laws of 7th century Medina. If slavery wasn't meant to be eliminated, why did the companions of the Prophet free 39,237 slaves?