At the onset of X-chromosome inactivation, the vital process whereby female mammalian cells equalize X products with respect to males, the X chromosomes are colocalized along their Xic (X-inactivation center) regions. The mechanism inducing recognition and pairing of the Xs remains, though, elusive. Starting from recent discoveries on the molecular factors and on the DNA sequences (the so-called pairing sites) involved, we dissect the mechanical basis of Xic colocalization by using a statistical physics model. We show that soluble DNA-specific binding molecules, such as those experimentally identified, can be indeed sufficient to induce the spontaneous colocalization of the homologous chromosomes but only when their concentration, or chemical affinity, rises above a threshold value as a consequence of a thermodynamic phase transition. We derive the likelihood of pairing and its probability distribution. Chromosome dynamics has two stages: an initial independent Brownian diffusion followed, after a characteristic time scale, by recognition and pairing. Finally, we investigate the effects of DNA deletion/insertions in the region of pairing sites and compare model predictions to available experimental data.