Tin–lead (Sn–Pb) mixed perovskite solar cells (PSCs) offer the potential for higher power conversion efficiency (PCE) than their pure lead counterparts. However, the lack of a well-defined Sn/Pb compositional profile results in disordered internal electric fields, limiting carrier separation. Here, we introduce a SnI2 predeposition strategy that induces a vertical Sn/Pb composition gradient within the perovskite film. This gradient forms a continuous heterojunction, establishing a built-in electric field that enhances carrier separation and directional extraction. As a result, the optimized devices achieve a PCE of 23.2% along with improved stability, retaining 89.6% of their initial efficiency after 1032 h of storage in nitrogen. This work demonstrates a compositional and interfacial engineering approach for advancing the efficiency and durability of Sn–Pb mixed PSCs.