Solar cells based on metal halide perovskites are one of the most promising photovoltaic technologies1,2,3,4. Over the past few years, the long-term operational stability of such devices has been greatly improved by tuning the composition of the perovskites5,6,7,8,9, optimizing the interfaces within the device structures10,11,12,13, and using new encapsulation techniques14,15. However, further improvements are required in order to deliver a longer-lasting technology. Ion migration in the perovskite active layer—especially under illumination and heat—is arguably the most difficult aspect to mitigate16,17,18. Here we incorporate ionic liquids into the perovskite film and thence into positive–intrinsic–negative photovoltaic devices, increasing the device efficiency and markedly improving the long-term device stability. Specifically, we observe a degradation in performance of only around five per cent for the most stable encapsulated device under continuous simulated full-spectrum sunlight for more than 1,800 hours at 70 to 75 degrees Celsius, and estimate that the time required for the device to drop to eighty per cent of its peak performance is about 5,200 hours. Our demonstration of long-term operational, stable solar cells under intense conditions is a key step towards a reliable perovskite photovoltaic technology