Using ab initio molecular dynamics simulations, we show that oxygen (O) impurities have a noticeable influence on the glass-formation ability (GFA) in Zr2Cu alloy. Cu-centered icosahedral clusters and Zr-centered Kasper polyhedra are the dominate short-range orders in undercooled Zr2Cu liquid which are most likely to be responsible for the glass formation in Zr2Cu systems. When O is introduced, a Zr octahedron is formed around the O impurity. Most of the Zr atoms in the octahedron also serve as the bridging atoms for cross-linked Kasper polyhedral network, resulting in an O-centered medium range order (MRO) structure. Meanwhile, Cu atoms are moved away from the first shell of O-centered octahedral clusters. With 1 at. % O impurities, the fractions of Zr-centered clusters are less affected, while the increase of ideal icosahedral order and decrease of distorted icosahedral order lead to a more stable atomic structure. This result suggests that a low concentration of O impurities would improve the GFA in Zr2Cu alloy. However, when ∼5 at. % O impurities are included, the ideal icosahedral clusters and Zr-centered Kasper polyhedra are seriously suppressed by the formation of O-centered MRO, which can lead to deterioration of GFA. Our analyses provide useful insight into glass formation behavior in O-doped metallic alloy systems.