Arabs, in the days of ignorance, i.e., before Islam, were steeped in idolatry and all types of injustices against humanity. They were divided in tribes and regularly raided other tribes to take free people into slavery. They committed the most heinous crimes against these slaves without feeling any remorse. Prophet Muhammad, even before he was commissioned by God as a prophet, valued human dignity and was against slavery. When he got married at the age of 25 to a rich widow, Khadija, she offered all her worldly possessions to him. This included many slaves she had had. The prophet right away freed all the slaves.
Islam's message of human dignity and equality of human spirit was so powerful that the early followers were from among the slaves of Mecca. One of the most pious deeds that Islam encouraged Muslims to adopt was freeing of the slaves. Prophet Muhammad banned the Arab practice of raids to take slaves. He said that no free man could ever be taken into slavery.
Muslims were taught to avoid confrontation even with their avowed enemies at all cost. When the persecution became unbearable, the prophet advised Muslims to emigrate to neighboring states in search of peace. Even he himself had to leave his beloved city of Mecca for Medina, a city-state 250 miles away, to avoid confrontation and to find a place of refuge for the nascent community of Muslims.
When war was imposed on the Muslims, they were at last permitted to fight back in self-defense to preserve their survival. [Qur'an 22:40] Those of the enemy who had come to destroy them, if taken as prisoners of war, were to be freed either through grace or by taking just compensation from the enemy. [Qur'an 47:5] The rest were offered freedom in exchange for either teaching some number of Muslim children to read and write, or to pay back an agreed upon amount as compensation by working independently as free men. [Qur'an 24:34]
Those who could not get their freedom by any of these ways were distributed among those who had participated in the defensive war. (There were no state prisons in those days.) But they were obligated to feed the prisoners just as they fed themselves and clothe and house them similarly. If any of the Muslims struck those under their care, they were told that unless they freed them right away, they would be severely punished by God.
Prophet Muhammad thus laid down the foundation for complete emancipation of slaves and the end of barbaric treatment of slaves at the hands of their masters. Throughout the 23 years of his ministry he continued to emphasize the values of human dignity and freedom, passing on as his last will and testament the Charter of Human Rights declared 14 centuries ago.