Perovskite solar cells (PSCs) with mesoporous TiO2 (mp-TiO2) as the electron transport material attain power conversion efficiencies (PCEs) above 22%; however, their poor long-term stability is a critical issue that must be resolved for commercialization. Herein, it is demonstrated that the long-term operational stability of mp-TiO2 based PSCs with PCE over 20% is achieved by isolating devices from oxygen and humidity. This achievement attributes to systematic understanding of the critical role of oxygen in the degradation of PSCs. PSCs exhibit fast degradation under controlled oxygen atmosphere and illumination, which is accompanied by iodine migration into the hole transport material (HTM). A diffusion barrier at the HTM/perovskite interface or encapsulation on top of the devices improves the stability against oxygen under light soaking. Notably, a mp-TiO2 based PSC with a solid encapsulation retains 20% efficiency after 1000 h of 1 sun (AM1.5G including UV) illumination in ambient air.