Short answer
The Bible lets an Israelite soldier who sees a beautiful woman among the captives take her home as his wife. She shaves her head and mourns her parents for a month. Then "thou shalt go in unto her". She is never asked. If he no longer wants her, he must let her go, "because thou hast humbled her". In Numbers, Moses orders every boy and every woman who had known a man to be killed. He tells the soldiers to keep the girls who had not "for yourselves". In Judges, the men of Benjamin are told to seize girls dancing at Shiloh as wives. Islam found slavery everywhere and bound it with rules. Today Muslim scholars hold slavery forbidden.
Full explanation
The beautiful captive
Deuteronomy gives a law for the soldier who sees "among the captives a beautiful woman" and desires her. He brings her home. She shaves her head, pares her nails, takes off the clothes of her captivity and mourns her father and mother for a full month. "After that thou shalt go in unto her, and be her husband". If he then has no delight in her, he must let her go and may not sell her, "because thou hast humbled her". The law gives her a month and forbids her sale. It never asks whether she is willing, and her parents may have died at the hands of the same army.
“When thou goest forth to war against thine enemies, and the Lord thy God hath delivered them into thine hands, and thou hast taken them captive, And seest among the captives a beautiful woman, and hast a desire unto her, that thou wouldest have her to thy wife; Then thou shalt bring her home to thine house; and she shall shave her head, and pare her nails; And she shall put the raiment of her captivity from off her, and shall remain in thine house, and bewail her father and her mother a full month: and after that thou shalt go in unto her, and be her husband, and she shall be thy wife. And it shall be, if thou have no delight in her, then thou shalt let her go whither she will; but thou shalt not sell her at all for money, thou shalt not make merchandise of her, because thou hast humbled her.”
Women as spoil
Deuteronomy's law of war says that when a city falls, "the women, and the little ones, and the cattle, and all that is in the city" are spoil for the winners to take. After the war with Midian, Moses was angry that the soldiers had let the women live. He ordered them to kill every male child, and every woman who had known a man. And he told them to keep alive "for yourselves" all the girls who had not.
“But the women, and the little ones, and the cattle, and all that is in the city, even all the spoil thereof, shalt thou take unto thyself; and thou shalt eat the spoil of thine enemies, which the Lord thy God hath given thee.”
“And Moses was wroth with the officers of the host, with the captains over thousands, and captains over hundreds, which came from the battle. And Moses said unto them, Have ye saved all the women alive? Behold, these caused the children of Israel, through the counsel of Balaam, to commit trespass against the Lord in the matter of Peor, and there was a plague among the congregation of the Lord. Now therefore kill every male among the little ones, and kill every woman that hath known man by lying with him. But all the women children, that have not known a man by lying with him, keep alive for yourselves.”
Wives taken by force
In Judges, the tribe of Benjamin had lost its women in war. Israel's assembly sent twelve thousand men against the town of Jabesh-gilead. Their orders were to kill every male, and every woman who had lain with a man. They found four hundred young virgins, and gave them to the men of Benjamin. When these were not enough, the elders told the men of Benjamin to hide in the vineyards at Shiloh. They were to wait for the girls to come out to dance, and each catch a wife and carry her off. The Law also says that a man who seizes an unbetrothed virgin and lies with her must pay her father fifty shekels, and marry her.
“And the congregation sent thither twelve thousand men of the valiantest, and commanded them, saying, Go and smite the inhabitants of Jabesh–gilead with the edge of the sword, with the women and the children. And this is the thing that ye shall do, Ye shall utterly destroy every male, and every woman that hath lain by man. And they found among the inhabitants of Jabesh–gilead four hundred young virgins, that had known no man by lying with any male: and they brought them unto the camp to Shiloh, which is in the land of Canaan. And the whole congregation sent some to speak to the children of Benjamin that were in the rock Rimmon, and to call peaceably unto them. And Benjamin came again at that time; and they gave them wives which they had saved alive of the women of Jabesh–gilead: and yet so they sufficed them not.”
“Therefore they commanded the children of Benjamin, saying, Go and lie in wait in the vineyards; And see, and, behold, if the daughters of Shiloh come out to dance in dances, then come ye out of the vineyards, and catch you every man his wife of the daughters of Shiloh, and go to the land of Benjamin. And it shall be, when their fathers or their brethren come unto us to complain, that we will say unto them, Be favourable unto them for our sakes: because we reserved not to each man his wife in the war: for ye did not give unto them at this time, that ye should be guilty. And the children of Benjamin did so, and took them wives, according to their number, of them that danced, whom they caught: and they went and returned unto their inheritance, and repaired the cities, and dwelt in them.”
“If a man find a damsel that is a virgin, which is not betrothed, and lay hold on her, and lie with her, and they be found; Then the man that lay with her shall give unto the damsel’s father fifty shekels of silver, and she shall be his wife; because he hath humbled her, he may not put her away all his days.”
What Islam did, and what Muslims hold today
Islam found slavery everywhere, and the classical law bound the master with rules. A man could not touch a captive woman until a waiting period had passed. The Prophet (ﷺ) said he had decided to curse a man who meant to have relations with a captive woman near to giving birth. The Qur'an forbids forcing slave women into prostitution. The Hanbali jurist al-Buhuti held that a slave woman whose master forced himself on her when she could not bear it, and injured her, was to be set free. A woman who bore her master a child could never be sold and went free at his death. Today Muslim scholars hold slavery forbidden, and Egypt's official fatwa authority calls enslavement a crime. The page "Does Islam allow 'sex slaves'?" sets this out in full.
Abu Sa'id al-Khudri reports that after the battle at Awtas the Companions held back from the captive women, and Allah revealed Qur'an 4:24; they became lawful only once their waiting period ('idda) had ended.
Abu al-Darda reports that the Prophet (ﷺ) came upon a woman near to giving birth at the door of a tent, and on hearing that the man who owned her meant to have relations with her, said he had decided to curse him with a curse that would follow him into his grave.
“Let those who find not the wherewithal for marriage keep themselves chaste, until Allah gives them means out of His grace. And if any of your slaves ask for a deed in writing (to enable them to earn their freedom for a certain sum), give them such a deed if ye know any good in them: yea, give them something yourselves out of the means which Allah has given to you. But force not your maids to prostitution when they desire chastity, in order that ye may make a gain in the goods of this life. But if anyone compels them, yet, after such compulsion, is Allah, Oft-Forgiving, Most Merciful (to them),”
A study of slavery in the Islamic tradition and beside other societies. It shows that slavery was universal in the pre-modern world, sets out the rules of Islamic law on slaves and concubines, and reports that classical jurists protected a slave woman under the law against harm rather than in the modern language of consent: the Hanbali jurist al-Buhuti held that if her master forced himself on her when she could not bear it and injured her, she was to be set free.
Malik reports from Nafi, from Ibn Umar, that the Caliph Umar ruled: when a slave woman bears her master a child, he may not sell her, give her away or leave her to his heirs; when he dies, she is free. This is Umar's ruling, not a saying of the Prophet (ﷺ).
Egypt's official fatwa authority states that Islamic law is clear in prohibiting slavery today, that the international agreements criminalising slavery bind Muslims, that enslavement has become a crime, and that the rulings on slaves in Islamic jurisprudence have been suspended because they no longer apply.
Perspectives
Jewish and Christian
Many Jews and Christians say Deuteronomy's law protected the captive woman. And they say the girls kept alive in Numbers were taken in as servants, not for sex.
Deuteronomy 21 protected the captive woman. She had a month to mourn, she became a wife, and she could not be sold.
Rebuttal
The law never asks whether she is willing. After the month, "thou shalt go in unto her", and if he tires of her she is sent away, "because thou hast humbled her". Her parents, whom she mourns, may have been killed by the same army.
The girls kept alive in Numbers 31 were taken in as servants or adopted, not kept for sex.
Rebuttal
The line between who lived and who died was whether a woman had "known man by lying with him". The girls were sorted by whether they were virgins, then kept "for yourselves". In Judges, the virgins of Jabesh-gilead were given to the men of Benjamin as wives.
The Islamic perspective
The Bible gives captive women to the winners, with no say of their own. Islam found slavery everywhere. It bound it with rules that protected the captive woman from harm. And Muslim scholars today hold slavery forbidden.
Deuteronomy lets a soldier take a beautiful captive as his wife without asking her.
Moses ordered the soldiers to keep alive for themselves the girls who had not known a man.
The Qur'an forbids forcing slave women into prostitution. And al-Buhuti held that a slave woman went free if her master forced himself on her and injured her.
Muslim scholars and fatwa authorities today hold slavery forbidden.