In this review we present a thoroughly comprehensive survey of recent work on modified theories of gravity and their cosmological consequences. Amongst other things, we cover General Relativity, Scalar-Tensor, Einstein-Aether, and Bimetric theories, as well as TeVeS, f (R), general higher-order theories, Hořava-Lifschitz gravity, Galileons, Ghost Condensates, and models of extra dimensions including Kaluza-Klein, Randall-Sundrum, DGP, and higher co-dimension braneworlds. We also review attempts to construct a Parameterised Post-Friedmannian formalism, that can be used to constrain deviations from General Relativity in cosmology, and that is suitable for comparison with data on the largest scales. These subjects have been intensively studied over the past decade, largely motivated by rapid progress in the field of observational cosmology that now allows, for the first time, precision tests of fundamental physics on the scale of the observable Universe. The purpose of this review is to provide a reference tool for researchers and students in cosmology and gravitational physics, as well as a self-contained, comprehensive and up-to-date introduction to the subject as a whole.