Slavery is legal practice in all major religions. Its only prohibited by laws now, due to the raised consciousness of human societies. We learnt with the passage of time that slavery is inhuman practice.
Since slavery is permitted by Islamic law, Muslim countries have used secular law to ban it. Some countries outlawed slavery only comparatively recently:
Qatar in 1952
Yemen and Saudi Arabia in 1962
Mauritania in 1980