This course begins by introducing the differential geometry of Lorentzian manifolds from scratch and then builds up quickly to the advanced framework in terms of differential forms and the vielbein formalism. These methods are then used to define general relativity, also as a gauge theory. We then study some of general relativity's deeper properties, such as the formalism of spinors, and aspects of the causal structure and singularities. One key goal is to lay the foundations for students who wish to proceed to studies in quantum gravity. We then apply general relativity to cosmological models and to cosmological perturbation theory. Thereby, we are covering the theory of cosmic inflation which is very successful in predicting, in particular, the properties cosmic microwave background radiation.