Formamidinium (FA)-based lead iodide perovskites have emerged as the most promising light-absorber materials in the prevailing perovskite solar cells (PSCs). However, they suffer from the phase-instability issue in the ambient atmosphere, which is holding back the realization of the full potential of FA-based PSCs in the context of high efficiency and stability. Herein, the tetraethylorthosilicate hydrolysis process is integrated with the solution crystallization of FA-based perovskites, forming a new film structure with individual perovskite grains encapsulated by amorphous silica layers that are in situ formed at the nanoscale. The silica not only protects perovskite grains from the degradation but also enhances the charge-carrier dynamics of perovskite films. The underlying mechanism is discussed using a joint experiment-theory approach. Through this in situ grain encapsulation method, PSCs show an efficiency close to 20% with an impressive 97% retention after 1000-h storage under ambient conditions.