Surface nanobubbles are nanoscopic gaseous domains on immersed substrates which can survive for days. They were first speculated to exist about 20 years ago, based on stepwise features in force curves between two hydrophobic surfaces, eventually leading to the first atomic force microscopy (AFM) image in 2000. While in the early years it was suspected that they may be an artifact caused by AFM, meanwhile their existence has been confirmed with various other methods, including through direct optical observation. Their existence seems to be paradoxical, as a simple classical estimate suggests that they should dissolve in microseconds, due to the large Laplace pressure inside these nanoscopic spherical-capshaped objects. Moreover, their contact angle (on the gas side) is much smaller than one would expect from macroscopic counterparts. This review will not only give an overview on surface nanobubbles, but also on surface nanodroplets, which are nanoscopic droplets (e.g., of oil) on (hydrophobic) substrates immersed in water, as they show similar properties and can easily be confused with surface nanobubbles and as they are produced in a similar way, namely, by a solvent exchange process, leading to local oversaturation of the water with gas or oil, respectively, and thus to nucleation. The review starts with how surface nanobubbles and nanodroplets can be made, how they can be observed (both individually and collectively), and what their properties are. Molecular dynamic simulations and theories to account for the long lifetime of the surface nanobubbles are then reported on. The crucial element contributing to the long lifetime of surface nanobubbles and nanodroplets is pinning of the three-phase contact line at chemical or geometric surface heterogeneities. The dynamical evolution of the surface nanobubbles then follows from the diffusion equation, Laplace's equation, and Henry's law. In particular, one obtains stable surface nanobubbles when the gas influx from the gas-oversaturated water and the outflux due to Laplace pressure balance. This is only possible for small enough surface bubbles. It is therefore the gas or oil oversaturation ζ that determines the contact angle of the surface nanobubble or nanodroplet and not the Young equation. The review also covers the potential technological relevance of surface nanobubbles and nanodroplets, namely, in flotation, in (photo)catalysis and electrolysis, in nanomaterial engineering, for transport in and out of nanofluidic devices, and for plasmonic bubbles, vapor nanobubbles, and energy conversion. Also given is a discussion on surface nanobubbles and nanodroplets in a nutshell, including theoretical predictions resulting from it and future directions. Studying the nucleation, growth, and dissolution dynamics of surface nanobubbles and nanodroplets will shed new light on the problems of contact line pinning and contact angle hysteresis on the submicron scale.