Two-dimensional/three-dimensional (2D/3D) perovskite heterojunctions at the contact interfaces have been proven to enhance the stability and power conversion efficiency (PCE) of perovskite solar cells (PSCs). The 2D/3D bilayer is typically formed via a solution post-treatment onto the 3D perovskite, where the 2D layer's dimensionality depends on the ligand size and its reactivity. Despite their stability, long-chain ligands typically form 2D perovskites with low dimensionality (n = 1, 2) which feature poor charge conductivity and mobility. Here, we propose an in situ fabrication method incorporating long-chain oleylammonium (OlyA+) ligands directly into the perovskite ink. This approach forms 2D perovskite with higher dimensionalities (n >= 3) with enhanced (001) crystal facet orientation of the 3D film, improved energetic alignment, charge extraction, and structural stability. The fabricated inverted PSCs with 1.55 eV bandgap achieved a maximum PCE of 26.22% for small area and 24.6% for 1cm2 devices, as well as 21.1% for mini-modules (6.8 cm2). Additionally, the PSCs with in situ formed 2D/3D perovskite heterojunctions retained 90% and 80% of their initial PCE after 1200 h photothermal stability and 1050 h outdoor testing, respectively. Our one-step strategy produces uniform and stable 2D/3D perovskite heterojunctions with enhanced passivation capability, overcoming the limitations of conventional sequential methods and offering a promising and effective approach for highly stable and efficient PSCs.