Y2O3 has attracted attention as the representative emerging candidate of a resistive switching (RS) medium in memristors due to its excellent electrical properties and good thermal stability. However, many challenges for Y2O3 film-based memristors remain to be resolved, particularly for the small switching window. Here, the doping engineering strategy is proposed, and in particular, the Mg doped amorphous Y2O3 film is adopted as the RS layer to construct memristors. The prepared Pt/Mg:Y2O3/Pt memristor exhibits a typical reproducible bipolar switching behavior with ultra-high HRS resistance and excellent switching window (>105), compared with the undoped counterparts (∼50). In addition, the multilevel storage capability is also achieved by controlling compliance current. Furthermore, the mechanisms and corresponding physical models for the striking RS characteristics for Pt/Mg:Y2O3/Pt memristors, stemming from the Mg dopant, are discussed and illustrated in detail. This work affords a deep understanding of RS mechanisms for Mg-doped Y2O3 film-based memristors and provides an effective strategy to enlarge the switching window for other transition metal oxide memristors.