This article sets out the framework of algebraic quantum field theory in curved spacetimes, based on the idea of local covariance. In this framework, a quantum field theory is modelled by a functor from a category of spacetimes to a category of (C * )-algebras obeying supplementary conditions. Among other things: (a) the key idea of relative Cauchy evolution is described in detail, and related to the stress-energy tensor; (b) a systematic 'rigidity argument' is used to generalise results from flat to curved spacetimes; (c) a detailed discussion of the issue of selection of physical states is given, linking notions of stability at microscopic, mesoscopic and macroscopic scales; (d) the notion of subtheories and global gauge transformations are formalised; (e) it is shown that the general framework excludes the possibility of there being a single preferred state in each spacetime, if the choice of states is local and covariant. Many of the ideas are illustrated by the example of the free Klein-Gordon theory, which is given a new 'universal definition'.