Gravitational waves (GWs) have a great potential to probe cosmology. We review early universe sources that can lead to cosmological backgrounds of GWs. We begin by presenting proper definitions of GWs in flat space-time and in a cosmological setting (section 2). Following, we discuss the reasons why early universe GW backgrounds are of a stochastic nature, and describe the general properties of a stochastic background (section 3). We recap current observational constraints on stochastic backgrounds, and discuss the basic characteristics of present and future GW detectors, including advanced LIGO, advanced Virgo, the Einstein telescope, KAGRA, and LISA (section 4). We then review in detail early universe GW generation mechanisms, as well as the properties of the GW backgrounds they give rise to. We classify the backgrounds in five categories: GWs from quantum vacuum fluctuations during standard slow-roll inflation (section 5), GWs from processes that operate within extensions of the standard inflationary paradigm (section 6), GWs from post-inflationary preheating and related non-perturbative phenomena (section 7), GWs from first order phase transitions related or not to the electroweak symmetry breaking (section 8), and GWs from general topological defects, and from cosmic strings in particular (section 9). The phenomenology of these early universe processes is extremely rich, and some of the GW backgrounds they generate can be within the reach of near-future GW detectors. A future detection of any of these backgrounds will provide crucial information on the underlying high energy theory describing the early universe, probing energy scales well beyond the reach of particle accelerators.