We apply variational tensor-network methods for simulating the Kosterlitz-Thouless phase transition in the classical two-dimensional XY model. In particular, using uniform matrix product states (MPS) with non-abelian O(2) symmetry, we compute the universal drop in the spin stiffness at the critical point. In the critical low-temperature regime, we focus on the MPS entanglement spectrum to characterize the Luttinger-liquid phase. In the high-temperature phase, we confirm the exponential divergence of the correlation length and estimate the critical temperature with high precision. Our MPS approach can be used to study generic two-dimensional phase transitions with continuous symmetries.