In the early mammalian embryo, X chromosome inactivation (XCI) achieves dosage parity between males and females for X-linked genes. During mouse development, imprinted paternal XCI is observed first and switches to random XCI in the epiblast but not placental lineages. The mechanism by which this epigenetic switch occurs is currently unknown. Here, we establish an ex vivo model for imprinting and identify a novel trans-acting regulatory factor for imprinted XCI. Using an induced trophoblast stem cell (iTS) model, we show that embryonic stem (ES) cells transdifferentiated into trophoblasts retain partial memory of the XCI imprint. Cdx2, a stem cell factor that determines commitment to the extraembryonic lineage, directly binds Xist and activates expression of Xist RNA in extrembryonic cells. Cdx2 competes with Oct4, a stem cell factor that determines commitment to the embryonic lineage, for overlapping binding sites within Xist. We propose that mutually exclusive binding between Cdx2 and Oct4 in Xist underlies the switch between imprinted and random XCI in the early mouse embryo.