To increase the commercial prospects of metal halide perovskite solar cells, there is a need for simple, cost-effective, and generalized approaches that mitigate their intrinsic thermal instability. Here we show that 1,3,7-trimethylxanthine, a commodity chemical with two conjugated carboxyl groups better known by its common name caffeine, improves the performance and thermal stability of perovskite solar cells based on both MAPbI 3 and CsFAMAPbI 3 active layers. The strong interaction between caffeine and Pb2+ ions serves as a “molecular lock” that increases the activation energy during film crystallization, delivering a perovskite film with preferred orientation, improved electronic properties, reduced ion migration, and greatly enhanced thermal stability. Planar n-i-p solar cells based on caffeine-incorporated pure MAPbI 3 perovskites, which are notoriously unstable, exhibit a champion-stabilized efficiency of 19.8% and retain over 85% of their efficiency under continuous annealing at 85°C in nitrogen.