• Functionalized nanofibers (N-CNFs) was produced by electrospinning. • N-CNFs was applied for guiding the oriented growth of perovskite for the first time. • N-CNFs provide nucleation sites as templates to induce crystalline orientation. • PCE of the devices with N-CNFs reaches 24.08% and excellent stability. Perovskite solar cell (PerSC) is currently one of the most promising third-generation photovoltaic technologies. However, the defects derived from the inhomogeneous growth of perovskite film exacerbate the charge recombination and ion migration in the devices, thus restricting their power conversion efficiency (PCE) and stability. In this work, we introduce nitrogen-doped carbon nanofibers (N-CNFs) via electrospinning technology to guide the preferential orientation of perovskite crystals for the first time. N-CNFs with abundant nitrogen-containing functional groups provide plentiful nucleation sites and fibrous templates, which guide the preferential orientation growth of crystals and diminish the defects density in the perovskite film. The PCE of the champion device achieved a remarkable improvement from 21.40% to 24.08% and demonstrated less than 5% degradation after 600 h of continuous exposure to the ambient environment. This study provides a novel strategy to realize efficient and stable PerSCs by controlling the heterogeneous nucleation and preferentially oriented growth of perovskite crystals with electrospinning N-CNFs.