There are always defects and oxygen vacancies in SnO2 prepared by solution methods, hindering efficient carrier transfer between SnO2 and the perovskite in perovskite solar cells. Thus, we employed MgAc2 to modify the interface. Carboxyl groups of MgAc2 filled the oxygen vacancies in SnO2, reducing its surface defect density, and Mg2+ partially replaced surface Sn4+, improving the properties of the SnO2 layer. Finally, perovskite solar cells modified with MgAc2 exhibited a significant improvement in open-circuit voltage and fill factor, improving the power conversion efficiency from 20.52% to 22.02%. Moreover, MgAc2-devices maintained 80% of the initial efficiency after 1250 h in thermal stability tests at 85 °C and 30% relative humidity compared to control devices. This work provides a method for treating the SnO2 electron transport layer and demonstrates the synergistic effects of Mg2+ and acetate ions, which can facilitate the development of efficient and stable perovskite solar cells.