We determine the lens spaces that arise by integer Dehn surgery along a knot in the three-sphere. Specifically, if surgery along a knot produces a lens space, then there exists an equivalent surgery along a Berge knot with the same knot Floer homology groups. This leads to sharp information about the genus of such a knot. The arguments rely on tools from Floer homology and lattice theory. They are primarily combinatorial in nature.