In this work we present a new mechanism for designing phase-gradient metasurfaces (PGMs) to control an electromagnetic wavefront with high efficiency. Specifically, we design a transmission-type PGM formed by a periodic subwavelength metallic slit array filled with identical dielectrics of different heights. It is found that when Fabry-Perot (FP) resonances occur locally inside the dielectric regions, in addition to the common phenomenon of complete transmission, the transmitted phase differences between two adjacent slits are exactly the same, being a non-zero constant. These local FP resonances ensure total phase shift across a supercell that can fully cover the range of 0 to 2Pi, satisfying the design requirements of PGMs. More studies reveal that due to local FP resonances, there is a one-to-one correspondence between the phase difference and the permittivity of the filled dielectric. A similar approach can be extended to the reflection-type case and other wavefront transformation, creating new opportunities for wave manipulation.