"harem," also the name of a former palace of the sultan in Istanbul, 1580s, from Italian seraglio, alteration of Turkish saray "palace, court," from Persian sara'i "palace, inn," from Iranian base *thraya- "to protect" (source also of Avestan thrayeinti "they protect"), from PIE *tra-, variant form of root *tere- (2) "cross over, pass through, overcome."
The Italian word probably reflects folk etymology influence of serraglio "enclosure, cage," from Medieval Latin serraculum "bung, stopper" (see serried).