Pebble accretion is the mechanism in which small particles ("pebbles") accrete onto big bodies (planetesimals or planetary embryos) in gas-rich environments. In pebble accretion, accretion occurs by settling and depends only on the mass of the gravitating body, not its radius. I give the conditions under which pebble accretion operates and show that the collisional cross section can become much larger than in the gas-free, ballistic, limit. In particular, pebble accretion requires the pre-existence of a massive planetesimal seed. When pebbles experience strong orbital decay by drift motions or are stirred by turbulence, the accretion efficiency is low and a great number of pebbles are needed to form Earth-mass cores. Pebble accretion is in many ways a more natural and versatile process than the classical, planetesimal-driven paradigm, opening up avenues to understand planet formation in solar and exoplanetary systems.