When you see among the captives a beautiful woman… (Deuteronomy 21:11)
If a soldier should happen to take a beautiful woman among the captives in battle, he must treat her according to a specified procedure. He is to take her into his house, where she shaves her head and lets her nails grow for a month, during which time she mourns the loss of her parents. (If they weren’t killed in the war, she’s certainly separated from them by circumstance.) All of these serve to make her less attractive.
The reason for this mitzvah is that it’s entirely possible that the soldier doesn’t truly love this woman; he may only have lust for her. Had the Torah prohibited her altogether, human nature would be to simply violate the law in the heat of the moment. By providing a permissible way for the soldier to marry this woman, he’s more likely to try to do it permissibly. (An analogous example would be the way in which online music piracy dropped sharply once they created an easy way to legally download songs.) This permissible course, however, includes a 30-day “cooling off period,” during which time a soldier might overcome a mere infatuation.
The law of the “beautiful woman” applies even if the woman in question is not objectively beautiful. All that matters is that she’s beautiful in the eyes of the soldier. (See Talmud Kiddushin 22a.) A soldier is limited to treating one captive according to the laws of the “beautiful woman,” no more. The “beautiful woman” must be converted and the soldier must marry her with the standard marriage contract, just like any other woman. If a year goes by and the woman has not consented to be converted, she must be released. (Compare with Talmud Yevamos 48b.)
This mitzvah applies at a time when the Jews occupy their land. It is discussed in the Talmud in tractate Yevamos (47b-48b) and in Kiddushin (21b-22a). It is codified in the Mishneh Torah in the eighth chapter of Hilchos Melachim and is #221 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.