The electron-selective contact layer (ESL) in organometal halide-based perovskite solar cells (PSCs) determines not only the power conversion efficiency (PCE) but also the thermostability of PSCs. To improve the thermostability of ZnO-based PSCs, we developed Mg-doped ZnO [Zn Mg O (ZMO)] as a high optical transmittance ESL for the methylammonium lead trihalide perovskite absorber [CH NH PbI ]. We further investigated the optical and electrical properties of the ESL films with Mg contents of 0-30 mol % and the corresponding devices. We achieved a maximum PCE of 16.5 % with improved thermal stability of CH NH PbI on ESL with the optimal ZMO (0.4 m) containing 10 mol % Mg. Moreover, this optimized ZMO PSC exhibited significantly improved durability and photostability owing to the improved chemical/photochemical stability of the wider optical bandgap ZMO.