There were many sources of slaves at the time of the advent of Islam, whereas the means of manumitting them were virtually nil. Islam changed the way in which slavery was dealt with; it created many new ways of liberating slaves, blocked many ways of enslaving people, and established guidelines which blocked these means.
Islam limited the sources of slaves that existed before the beginning of the Prophet ﷺ’s mission to one way only: enslavement through war which was imposed on non-Muslim prisoners-of-war and on their womenfolk and children.
Shaykh al-Shanqiti R said:
“The reason for slavery is kufr and fighting against Allah and His Messenger. When Allah enables the Muslim mujahidin who are offering their souls and their wealth, and fighting with all their strength and with what Allah has given them to make the word of Allah supreme over the kuffar, then He makes them their property by means of slavery unless the ruler chooses to free them for nothing or for a ransom, if that serves the interests of the Muslims.” (Adwa al-Bayan, 3/387)
He also said:
“If it is said: If the slave becomes Muslim then why keep him as a slave, when the reason for slavery is kufr and fighting against Allah and His Messenger, so this reason no longer applies?
The answer is that the well-known principle among the scholars and all wise people, which is that the previously established right cannot be erased by a right that is established later, and that what came first takes precedence, is obvious.
When the Muslims captured non-Muslims, their right to possession was affirmed by the law of the Creator of all, Who is All Wise and All Knowing. So this right is confirmed and established. Then if the slave became Muslim after that, his right to escape slavery by embracing Islam was superseded by the mujahid’s prior right to take possession of him before he became Muslim, and it would be unjust and unfair to annul the prior right because of a subsequent right, as is well known to all wise people. (Adwa al-Bayan, 3/389)
Capture of prisoners during war was the most common way of acquiring slaves. Prisoners would inevitably be captured during any war, and the prevalent custom at that time was that prisoners had no protection or rights; they would either be killed or enslaved. But Islam brought two more options: unconditional release or ransom. Allah says:
فَإِذَا لَقِيتُمُ ٱلَّذِينَ كَفَرُوا۟ فَضَرْبَ ٱلرِّقَابِ حَتَّىٰٓ إِذَآ أَثْخَنتُمُوهُمْ فَشُدُّوا۟ ٱلْوَثَاقَ فَإِمَّا مَنًّۢا بَعْدُ وَإِمَّا فِدَآءً حَتَّىٰ تَضَعَ ٱلْحَرْبُ أَوْزَارَهَا ۚ ذَٰلِكَ وَلَوْ يَشَآءُ ٱللَّهُ لَٱنتَصَرَ مِنْهُمْ وَلَـٰكِن لِّيَبْلُوَا۟ بَعْضَكُم بِبَعْضٍ ۗ وَٱلَّذِينَ قُتِلُوا۟ فِى سَبِيلِ ٱللَّهِ فَلَن يُضِلَّ أَعْمَـٰلَهُمْ
Therefore, when you meet the unbelievers in the battlefield, smite their necks and, when you have thoroughly subdued them, then take prisoners of war and bind them firmly. After the war lay down her burdens, then you have the choice whether you show them favour or accept ransom. Thus are you commanded. If Allah wanted, He Himself could have punished them; but He adopted this way so that He may test some of you by means of others. As for those who are slain in the cause of Allah, He will never let their deeds be lost. [Muhammad 47:4].
During the battle of Badr the Prophet ﷺ accepted ransoms from the mushrik prisoners of war and let them go, and the Messenger ﷺ let many of the prisoners go for free, releasing them with no ransom. During the conquest of Makkah it was said to the people of Makkah: “Go, for you are free.”
During the campaign of Banu’l-Mustaliq, the Messenger of Allah ﷺ married a female prisoner from the defeated tribe so as to raise her status, as she was the daughter of one of their leaders, namely the Mother of the Believers Juwayriyah bint al-Harith (may Allah be pleased with her). Then the Muslims let all of these prisoners go.
Islam is not thirsty for the blood of prisoners, nor is it eager to enslave them.
Thus we may understand the limited ways that can lead to slavery. Islam did not abolish it altogether, because the kafir prisoner who was opposed to truth and justice was a wrongdoer, or was a supporter of wrongdoing or was a tool in the execution or approval of wrongdoing. Letting him go free would give him the opportunity to spread wrongdoing and aggression against others and to oppose the truth and prevent it reaching people.
Freedom is a basic human right which cannot be taken away from a person except for a reason. When Islam accepted slavery within the limits that we have described, it put restrictions on the man who exploits his freedom in the worst possible way. If he was taken prisoner in a war of aggression in which he was defeated, then the proper conduct is to keep him in reasonable conditions throughout his detention.
Despite all that, Islam offers many opportunities to restore freedom to him and people like him.