This chapter describes the way in which modular invariance enters a consistent string theory. It discusses the way in which the requirement of modular invariance can be used in the construction of consistent four-dimensional heterotic string theories. The chapter describes the fermionic construction of four-dimensional heterotic string theories where all bosonic degrees of freedom other than those associated with four-dimensional space-time are fermionized. Before proceeding to the constraints imposed on the theories by modular invariance, it aims to establish notations for the boundary conditions for the fermionic degrees of freedom, and considers the requirements for world sheet supersymmetry. To construct a modular invariant partition function it is necessary in general to take a linear combination of terms with definite boundary conditions.