Conventional optical lenses focus electromagnetic waves by imparting position-dependent phase delay through shaping their geometry. This poses difficulties in eliminating the geometric aberrations in high numerical aperture lenses, in addition to the fabrication challenges when operating at short wavelengths (e.g. visible light), and bulky devices operating at long wavelengths (e.g. microwaves). In contrast, metasurfaces realize full control of phase through tailoring the subwavelength resonant structures, allowing for the demonstration ultrathin flat lens, although the efficiency is still rather low using single-layer metasurfaces. Here we report the demonstration of high-performance flat lens in the terahertz frequency range using few-layer metasurfaces. The three-layer metasurface structure is capable of rotating the incident linear polarization by 90° with a very high efficiency over a bandwidth of two octaves. More importantly, the phase of the output light can be tuned over the entire 2π range with subwavelength resolution through simply tailoring the structure geometry of the basic building blocks. Based on this success, we design, fabricate, and characterize a metasurface lens operating at 0.4 THz. With a lens diameter and focal length both 5 cm, we realize a high numerical aperture of 0.5 and diffraction-limited terahertz beam focusing. Terahertz time-domain spectroscopy measurements show that the metasurface lens is capable of achieving the same signal intensity as compared to a bulk TPX lens of the same size and focal length.