Pluripotency of embryonic stem (ES) cells is controlled by defined transcription factors. During differentiation, mouse ES cells undergo global epigenetic reprogramming, as exemplified by X-chromosome inactivation (XCI) in which one female X chromosome is silenced to achieve gene dosage parity between the sexes. Somatic XCI is regulated by homologous X-chromosome pairing and counting, and by the random choice of future active and inactive X chromosomes. XCI and cell differentiation are tightly coupled, as blocking one process compromises the other and dedifferentiation of somatic cells to induced pluripotent stem cells is accompanied by X chromosome reactivation. Recent evidence suggests coupling of Xist expression to pluripotency factors occurs, but how the two are interconnected remains unknown. Here we show that Oct4 (also known as Pou5f1) lies at the top of the XCI hierarchy, and regulates XCI by triggering X-chromosome pairing and counting. Oct4 directly binds Tsix and Xite, two regulatory noncoding RNA genes of the X-inactivation centre, and also complexes with XCI trans-factors, Ctcf and Yy1 (ref. 17), through protein-protein interactions. Depletion of Oct4 blocks homologous X-chromosome pairing and results in the inactivation of both X chromosomes in female cells. Thus, we have identified the first trans-factor that regulates counting, and ascribed new functions to Oct4 during X-chromosome reprogramming.