Varifocal lenses, conventionally implemented by changing the axial distance between multiple optical elements, have a wide range of applications in imaging and optical beam scanning. The use of conventional bulky refractive elements makes these varifocal lenses large, slow, and limits their tunability. Metasurfaces, a new category of lithographically defined diffractive devices, enable thin and lightweight optical elements with precisely engineered phase profiles. Here we demonstrate tunable metasurface doublets, based on microelectromechanical systems (MEMS), with more than 60 diopters (about 4%) change in the optical power upon a 1-μm movement of one metasurface, and a scanning frequency that can potentially reach a few kHz. They can also be integrated with a third metasurface to make compact microscopes (~1 mm thick) with a large corrected field of view (~500 μm or 40 degrees) and fast axial scanning for 3D imaging. This paves the way towards MEMS-integrated metasurfaces as a platform for tunable and reconfigurable optics.