Two-dimensional metamaterials (metasurfaces) have led to many exciting phenomena both in linear and nonlinear optics. In this talk I will present an overview of some recent results for both metallic and dielectric metasurfaces. Record second order nonlinearities can be obtained when metallic metasurfaces are coupled with resonant electronic transitions in semiconductors such as intersubband transitions. Additionally, since the nonlinear unit in this case is a single resonator coupled to the semiconductor heterostructure, additional functionality can be obtained at the second harmonic beam. This phenomena can be described as a phased-array source. Using this principle, we have created beam and polarization splitters operating at the second harmonic wavelength. This is new functionality that has no counterpart in conventional nonlinear optical materials. Another interesting case is the combination of all-dielectric metasurfaces with nonlinear optical phenomena, both bulk and surface enhanced. All-dielectric metasurfaces provide a platform to engineer magnetic and electric resonant modes in wavelength-scale nanoresonators with very low loss. Fabricating such dielectric metasurfaces from different types of semiconductors can be used to enhance their second and third order nonlinearities by several orders of magnitudes.