We introduce the notion of a Galois extension of commutative S-algebras (E∞ ring spectra), often localized with respect to a fixed homology theory. There are numerous examples, including some involving Eilenberg-Mac Lane spectra of commutative rings, real and complex topological K-theory, Lubin-Tate spectra and cochain S-algebras. We establish the main theorem of Galois theory in this generality. Its proof involves the notions of separable (and étale) extensions of commutative S-algebras, and the Goerss-Hopkins-Miller theory for E∞ mapping spaces. We show that the global sphere spectrum S is separably closed (using Minkowski's discriminant theorem), and we estimate the separable closure of its localization with respect to each of the Morava K-theories. We also define Hopf-Galois extensions of commutative S-algebras, and study the complex cobordism spectrum MU as a common integral model for all of the local Lubin-Tate Galois extensions.