A sandwich-plate model is developed to account for the effect of surface layers on the buckling of piezoelectric nanofilms (PNFs) due to an electrical voltage. The physical mechanisms of the surface effects are investigated and the contributions to the resultant effect are evaluated for surface piezoelectricity, surface stress and surface elasticity. It is found that the surface effect originates primarily from the residual surface stresses and enhanced piezoelectric coefficient due to the surface piezoelectricity. Its influence on the critical buckling voltage of a PNF depends sensitively on the thickness, the length-to-thickness ratio and the nature of residual surface stress. In addition, the intrinsic buckling may occur for a thin PNF where the relatively strong residual surface compression is achieved.