Xylene isomers are precursors in many important chemical processes, yet their separation via crystallization or distillation is energy intensive. Adsorption presents an attractive, lower-energy alternative and the discovery of adsorbents which outperform the current state-of-the-art zeolitic materials represents one of the key challenges in materials design, with metal-organic frameworks receiving particular attention. One of the most well-studied systems in this context is UiO-66(Zr), which selectively adsorbs ortho-xylene over the other C8 alkylaromatics. The mechanism behind this separation has remained unclear, however. In this work, we employ a wide range of computational techniques to explore both the equilibrium and dynamic behavior of the xylene isomers in UiO-66(Zr). In addition to correctly predicting the experimentally-observed ortho-selectivity, we demonstrate that the equilibrium selectivity is based upon the complete encapsulation of ortho-xylene within the pores of the framework. Furthermore the flexible nature of the adsorbent is crucial in facilitating xylene diffusion and our simulations reveal for the first time significant differences between the intracrystalline diffusion mechanisms of the three isomers resulting in a kinetic contribution to the selectivity. Consequently it is important to include both equilibrium and kinetic effects when screening MOFs for xylene separations.