Equations arising in general relativity are usually too complicated to be solved analytically and one must rely on numerical methods to solve sets of coupled partial differential equations. Among the possible choices, this paper focuses on a class called spectral methods in which, typically, the various functions are expanded in sets of orthogonal polynomials or functions. First, a theoretical introduction of spectral expansion is given with a particular emphasis on the fast convergence of the spectral approximation. We then present different approaches to solving partial differential equations, first limiting ourselves to the one-dimensional case, with one or more domains. Generalization to more dimensions is then discussed. In particular, the case of time evolutions is carefully studied and the stability of such evolutions investigated. We then present results obtained by various groups in the field of general relativity by means of spectral methods. Work, which does not involve explicit time-evolutions, is discussed, going from rapidly-rotating strange stars to the computation of black-hole–binary initial data. Finally, the evolution of various systems of astrophysical interest are presented, from supernovae core collapse to black-hole–binary mergers.