Slave women, who had male masters, were allowed conjugal relations with their masters. This was allowed in Islam. Islam only allows people to become slaves as a result of war, because such people had to be taken captive in order to quell the threat of their attacking again in the future. There were women who also participated in battles, but they helped with medical care, giving water to the troops and goading the men on to battle. Those women who were on the enemy side were taken captive. Also, when a city or fortress as seized, those women were taken captive as well, whether their men were kept alive or killed. Sometimes they were ransomed and freed. Usually there was an exchange of prisoners of war.
Women who are taken captive, were not forced into sexual relations, but they could consent to it because that was allowed. Those women were not always freed, sometimes they would remain slaves. Thus, either they were freed through ransoming, or they eventually became free through being an Umm Walad. An Umm Walad is one who has a child by her slave master. That woman is freed as a consequence, and the child is the master's heir, acquiring inheritance from his/her father. The child and the Umm Walad are free and can never be enslaved again.
Reasons for why this occurred:
-Marriage is only allowed with up to four women, sometimes other women, through war, will need a man who can act as her husband. Thus, her master owns her, but she has the status of a wife with him. If a man already has four wives, then this is the only way she can have a man if, in a worst case scenario, every man in a society has four women as wives already (one extreme case).
-Another reason is that the child born to the master becomes an inheritor. I mentioned this already, but in Islamic history, many of the Khulafa, Umayyads and Abbasids, were themselves children of slave women, many Roman and in the rare case Turkish. Thus, most Khulafa in the prime history of Islam, had mothers who were Umm Walad. That is how they got to be heirs to the Khilafat. There are many love stories between the past Khulafa and their Umm Walads. Even in the Ahadith there is mention of how some Companions (ra) had love for their Umm Walads. So these women were not mere property of men, they had rights like other slaves, but even more so since they were like wives to their masters.
Also, the reason why this was allowed, the last piece of my explanation to you, is that the enemies of Islam tried to fight the Muslims in order to make their women their enslaved captives for their own lust. Thus, Muslims were allowed to retaliate and do the same to the disbelievers, and have conjugal relations with their wives.
To be very clear, no rape was allowed. The Holy Prophet (saw) did not advocate this, and neither does his example. Take the example of Rayhana, Juwayriya and Safiyyah. The Holy Qur'an only allows retaliation, no transgression against enemies. I have no specific reference for this since I am just giving you the facts and it is up to you to look them up in detail or not.
If you are still unclear on any of this, I can explain further. This issue bothered me for a while because of all the anti-Islamic rhetoric surrounding it, but it is really quite easy to understand once you have read up on it. There are debates and discussions on youtube where some Islamic scholars have explained this issue in various ways. This is really a beautiful treatment of slave women in Islam, and you can see why with the historical precedence I gave you. These women were loved by their masters, and so were their children adored by them. They were, in reality, family to their masters, and not mere chattel and property to be simply used and discarded. It is incorrect to refer to such women as sex slaves, they were concubines who were treated as wives.
The Holy Qur'an teaches that husbands and wives are there to comfort one another, and many other beautiful teachings. Thus, this relation is also beautiful and full of love and compassion. It was instituted to help get rid of slavery. It expanded families and elevated slaves to the same status as their masters. This was a serious problem before Islam came. Thus, Islam got rid of this huge rift in classes of people.