Defects at the top and bottom interfaces of three-dimensional (3D) perovskite photoabsorbers diminish the performance and operational stability of perovskite solar cells owing to charge recombination, ion migration and electric-field inhomogeneities1-5. Here we demonstrate that long alkyl amine ligands can generate near-phase-pure 2D perovskites at the top and bottom 3D perovskite interfaces and effectively resolve these issues. At the rear-contact side, we find that the alkyl amine ligand strengthens the interactions with the substrate through acid-base reactions with the phosphonic acid group from the organic hole-transporting self-assembled monolayer molecule, thus regulating the 2D perovskite formation. With this, inverted perovskite solar cells with double-side 2D/3D heterojunctions achieved a power conversion efficiency of 25.6% (certified 25.0%), retaining 95% of their initial power conversion efficiency after 1,000 h of 1-sun illumination at 85 °C in air.