borrowed from Latin ex- (before vowels and voiceless consonants), ē- (from *egz-, before voiced consonants), from ex, ē, preposition, "out of, from," going back to Indo-European *h1eḱ-s or *h1eǵh-s, whence also Old Irish a, as "out of, from," Middle Welsh ech, Greek ex, ek, Lithuanian ìš, ìž, Old Church Slavic iz (with unexplained i in Balto-Slavic); (sense 3) borrowed from Late Latin, as in exconsul "former consul," based on Latin ex in the sense "from being, having formerly held (an office)," as in ex assessōre praefectus praetōriī "advanced from the position of judge's assistant to commander of the Praetorian Guard" (Suetonius)
Prefix (2)
borrowed from Greek ex-, ek-, from ex, ek, preposition, "out of, from" — more at ex- entry 1