One of the reasons that slavery lasted so long in the Islamic world is that Muhammad made it far more humane than he found it. Sexual slavery is specifically permitted in the Koran, but enslavers were required to adopt their children born to slaves, and they were not permitted to separate families. It was also possible for a slave to sue his enslaver in court if they were mistreated. This doesn't mean that slaves were always treated according to these laws. In fact, the official reason that slavery was abolished in Saudi Arabia (in 1962!) was that slaves weren't actually being treated according to the rules in Islamic Law. More on this here.