Slavery has been rife throughout all of ancient history. Most, if not all, ancient civilizations practiced this institution and it is described (and defended) in early writings of the Sumerians, Babylonians, and Egyptians. It was also practiced by early societies in central America and Africa. (See Bernard Lewis"s work Race and Slavery in the Middle East 1 for a detailed chapter on the origins and practices of slavery.)
The Qur"an prescribes a humanitarian approach to slavery -- free men could not be enslaved, and those faithful to foreign religions could live as protected persons, dhimmis, under Muslim rule (as long as they maintained payment of taxes called Kharaj and Jizya). However, the spread of the Islamic Empire resulted in a much harsher interpretation of the law. For example, if a dhimmis was unable to pay the taxes they could be enslaved, and people from outside the borders of the Islamic Empire were considered an acceptable source of slaves.
Although the law required owners to treat slaves well and provide medical treatment, a slave had no right to be heard in court (testimony was forbidden by slaves), had no right to property, could marry only with permission of their owner, and was considered to be a chattel, that is the (moveable) property, of the slave owner. Conversion to Islam did not automatically give a slave freedom nor did it confer freedom to their children.
Whilst highly educated slaves and those in the military did win their freedom, those used for basic duties rarely achieved freedom. In addition, the recorded mortality rate was high -- this was still significant even as late as the nineteenth century and was remarked upon by western travelers in North Africa and Egypt.
Slaves were obtained through conquest, tribute from vassal states (in the first such treaty, Nubia was required to provide hundreds of male and female slaves), offspring (children of slaves were also slaves, but since many slaves were castrated this was not as common as it had been in the Roman empire), and purchase.