Nearer to our own time, we have the western European variety of slavery. The barbarity and bestiality of this enormous trade beggars all description. The trade was principally in Africans who were transported across the oceans, packed in specially designed ships, and considered and treated as livestock. These slaves were forced to change their names, abandon their religion and language, deprived of all hope for freedom, and were kept for labor or breeding purposes. A birth among them was celebrated as if it were a death.
It is difficult to understand how human beings could conceive of fellow human beings in such a light, still less treat them thus. But it certainly happened. Documentary evidence shows, for example, how shipmasters would throw their human cargo overboard to claim compensation for their loss. Slaves had no legal or other rights, but only obligations. Their owners had the absolute right to dispose of them as they wished—brothers and sisters, parents and children, were separated or allowed to stay together according to the owner's mood or economic convenience.
Centuries of this dreadful practice made western Europe rich from its slave-based exploitation of such commodities as sugar, cotton, coffee. When it abolished slavery, first as a trade and then altogether with much self-congratulation, only the slave-owners were compensated. In other words, the attitudes that made slavery possible remained.
Not many years after its abolition, Africa was colonized by western Europe with consequences for the Africans no less terrible than slavery itself. Moreover, because their attitude to non-Europeans has changed little, if at all, the slaves' descendants continue to live in poor social and political conditions. Those who live amid Europeans remain despised inferiors. Anthropological museums in western European capitals only closed their public displays of bones and stuffed bodies of fellow (but non-white) human beings several decades ago—displays that had been organized by European scientists, doctors, learned people, and humanitarians.
In short, the institution of slavery disgusts the human heart, as do the attitudes of inhumanity that sustain it. If the institution no longer formally exists but the attitudes persist, can we say that humanity has made any progress? This is why colonial exploitation replaced slavery, and why the chains of unbearable, unrepayable international debt have replaced colonial exploitation. Slavery has disappeared, but its inhuman and barbarous structures are still securely in place.
Before we turn to the Islamic perspective on slavery, let's recall a name famous even among western Europeans: Harun al-Rashid. This ruler, who enjoyed such authority and power over Muslims, was the son of a slave. Nor is he the only such example. Slaves and their children enjoyed enormous prestige, authority, respect, and (shall we say it) freedom within the Islamic system, in all cultural, political, and other spheres of life. How was this possible?
Islam amended the institution of slavery and educated masters about slaves. The Qur'an states many times that everyone is descended from a single ancestor (Adam), and that no one is inherently superior to anyone else because of race, nation, or social standing. The Prophet applied these principles in his own life, and his Companions learned them and accepted them as laws and as social norms. The Prophet stated:
"Whoever kills a slave shall be killed. Whoever imprisons and starves a slave will be imprisoned and starved. Whoever castrates a slave will be castrated." 
"You are sons of Adam, and Adam was created from clay." 
"No Arab is superior to a non-Arab, and no non-Arab is superior to an Arab. No white person is superior to a black person, and no black person is superior to a white person. Superiority is based on righteousness and God-fearing alone." 
Because of this compassionate attitude, slaves and those described as poor and lowly were respected by those who enjoyed high social status.  'Umar expressed such respect when he said: "Master Bilal, whom Master Abu Bakr set free." 
Unlike other civilizations, Islam requires that slaves be thought of and treated within the framework of universal human brotherhood. The Prophet said: "Your servants and your slaves are your brothers (and sisters). Those who have slaves should give them from what they eat and wear. They should not charge their slaves with work beyond their capabilities. If you must set them to hard work, in any case I advise you to help them." He also said: "None of you should (when introducing someone) say: 'This is my (male) slave' or 'This is my female slave.' Rather, call them 'my daughter,' 'my son,' or 'my brother.'"
For this reason, 'Umar and his slave took turns riding a camel while traveling from Madina to Jerusalem to take control of Masjid al-Aqsa. While he was caliph, 'Uthman had his slave pull his own ears in public, since he had pulled his. The Companion Abu Dharr, applying the hadith literally, made his slave wear one half of his suit while he wore the other half. These Muslims, and many others, showed succeeding generations of Muslims how to treat slaves as full human beings worthy of the same respect, dignity, and justice given to non-slaves.
This constructive and positive treatment necessarily affected the master's attitude. Slaves retained their humanity and moral dignity, and had a place within the master's family. Even when they were freed, not all wanted to leave their masters. Starting with Zayd ibn Harith, this practice became quite common. Although the Prophet gave Zayd his freedom, the latter chose to remain. Masters and slaves were able to regard each other as brothers and sisters because their faith enabled them to understand that differences between people are not permanent. Therefore, neither haughtiness nor rancor were acceptable.
 Tirmidhi, Tafsir, 49; Manaqib, 73; Abu Dawud, Adab, 111.
 Ibn Hanbal, Musnad, 411.
 Muslim, Birr, 138; Jannat, 48; Tirmidhi, Manaqib, 54, 65.
 Bilal, one of the earliest Muslims, was a black Ethiopian slave. He eventually was chosen by the Prophet to be the official muezzin (caller to prayer) of the Muslim community. Abu Bakr, one of the pre-Islamic Makkan elite and also an early convert, was the Prophet's political successor and the first of the Rightly-Guided Caliphs. Bukhari, Fada'il al-Sahaba, 23.
In addition, there were strict principles enforced as law, such as: "Whoever kills a slave shall be killed; whoever imprisons and starves a slave shall be imprisoned and starved." Besides sanctions mandating proper treatment, slaves also enjoyed the legal right to earn money and hold property independently of their masters, to keep their religion, and to have a family and family life with the attendant rights and obligations. Along with personal dignity and a degree of material security, Islamic laws and norms allowed slaves a still more precious opening—the hope and means of freedom.
Human freedom is God-given, and therefore everyone's natural and proper condition. Thus to restore a person, either wholly or partly, to this condition is one of the highest virtues. Freeing half of a slave's body is considered equal to saving half of one's own body from God's wrath in the next world. Freeing a slave's whole body is considered equal to saving one's whole body. Seeking freedom for enslaved people is an acceptable reason for engaging in warfare. Muslims were encouraged to enter into agreements and contracts that enabled slaves to earn or be granted their freedom after a certain time or, most typically, on the owner's death. Unconditional emancipation was regarded as most meritorious and worthy in the Hereafter. Sometimes groups of people would buy and free large numbers of slaves in order to obtain God's favor.
Freeing a slave also was the legal expiation for certain sins or failures in religious duties, such as breaking an oath or a fast—a good deed to cancel a moral lapse. The Qur'an orders that a person who accidentally kills a Muslim must free a believing slave and pay the blood-money to the victim's family (4:92). A killing affects both the society and the victim's family. The blood-money is a partial compensation for the latter, while freeing a slave is a bill paid to the community—it gains a free person. To free a living person in return for a death was considered like bringing someone back to life. Both personal and public wealth was used to free slaves. The Prophet and Abu Bakr were known for this practice. Later on, especially during the reign of 'Umar ibn 'Abd al-'Aziz, public zakat funds were used for this purpose.
A possible question: Islam regards slavery as a social evil, regardless of how well slaves are treated or how many rights they enjoy. Therefore, why was it not abolished, as happened with alcohol, interest, gambling, or prostitution? Why did the Prophet condone it?
Until the evil of the European slave trade, slavery was largely a byproduct of war, for the victors normally enslaved the survivors. During Islam's early years, there was no reliable system of exchanging prisoners of war. The available means of dealing with them were execution, placing them in prison, allowing them to go home, or distributing them among the Muslims as spoils of war.
The first option must be ruled out on the grounds of its barbarity. The second is practicable only for small numbers and for a limited period of time, provided that there are enough resources to care for them. This option was used, for prisoners were taken in the hope of ransom payments. Many Makkans held by the Muslims were so satisfied with their treatment that they became Muslims and changed sides. The third option is imprudent in times of war. This leaves, as a general practice, only the fourth option. Islam instituted humane laws and norms for what is, in effect, the rehabilitation of prisoners of war.
While living among Muslims, slaves saw at close quarters the truth of Islam in practice. Many slaves were won over by the kind treatment they received and Islam's humanity, not to mention their access to many of the legal rights enjoyed by Muslims, and, ultimately, by the chance to regain their freedom. Thousands of ex-slaves can be found among the great and famous names in Islam, and their won examples became a norm for future Muslims—imams such as Nafi' (Imam Malik's teacher) and Tawus ibn Qaisan, to name only two.
In general, Muslims considered slavery a temporary condition. Unlike Western civilization, whose values are now so much in fashion, slavery was not an inherited condition that engulfed whole generations in deepening spirals of degradation, despair, and hopelessness. On the contrary, enjoying a status as fundamentally equal to everyone else, slaves in Muslim society could and did live in secure possession of their dignity as creatures of the same Creator. They had access to the mainstream of Islamic culture and civilization—to which, as we have noted, they contributed greatly. In Western societies where slavery was widespread, particularly in North and South America, the descendants of slaves, even generations after their ancestors' formal emancipation, remain largely on the fringes of society, a sub-culture or anti-culture—which is only sometimes tolerated, and mostly despised, by the dominant community.
When the Muslims were secure against foreign conquest, why did they not free all of their former captives or slaves? Again, the answer has to do with existing realities. Those former captives or slaves did not have the personal, psychological, or economic resources needed to establish a secure and dignified independence. Remember what happened in the United States when the slaves were suddenly freed by President Lincoln. Many were abruptly reduced to destitution and homelessness by their former owners (who were compensated) who no longer accepted any responsibility for them. They were thrown, without any preparation, into the wider society from which they had been so long excluded by law.
In contrast, observant Muslim masters who embraced their slaves as brothers and sisters encouraged them to work for their freedom, recognized their rights, helped them support a family, and helped them find a place in society before freeing them. The example that comes to mind is that of Zayd ibn Harith, who was brought up in the Prophet's own household and set free. He married a noblewoman and was appointed commander of a Muslim army composed of many noblemen and Companions. There are many similar examples.
There are two important points to emphasize here: the Muslims' attitude toward slavery, and the condition of slaves in non-Muslim countries. Islam considers slavery an accidental and therefore temporary condition, one that is to be reformed step by step until it almost completely disappears. However, it has been observed that some Muslims, especially rulers, continued to hold slaves. Islam cannot be blamed for this, for it is the individual Muslim's own spiritual deficiency that caused him or her to behave in such a manner.
The other point is that personal habits engender a second nature. When Lincoln abolished slavery, most slaves had to return to their former owners because they had never learned how to take the initiative and choose for themselves. As a result, they could not live as free people. Given this psychological reality, prisoners of war were distributed among Muslims so that one day they could live a true Islamic social life as free people in a Muslim society and enjoy their full legal rights.
Islam sought to abolish slavery gradually. In the first step, it enabled slaves to realize their true human consciousness and identity. After that, it educated them in Islamic and human values, and inculcated in them a love of freedom. Thus, when they were freed, former slaves were equipped to consider all kinds of possibilities related to becoming useful members of the community: farmers, artisans, teachers, scholars, commanders, governors, ministers, or even prime ministers.
Islam attempted to destroy the institution of "individual slavery," and never envisaged or tried "national slavery." So, as a Muslim, I pray to God that enslaved—colonized, oppressed—peoples will enjoy real freedom.