This article contains an elementary constructive proof of resolution of
singularities in characteristic zero. Our proof applies in particular to
schemes of finite type and to analytic spaces (so we recover the great theorems
of Hironaka). We introduce a discrete local invariant $\inv_X (a)$ whose
maximum locus determines a smooth centre of blowing up, leading to
desingularization. To define $\inv_X$, we need only to work with a category of
local-ringed spaces $X=(|X|,{\cal O}_X)$ satisfying certain natural conditions.
If $a\in |X|$, then $\inv_X(a)$ depends only on $\widehat{\cal O}_{X,a}$. More
generally, $\inv_X(a)$ is defined inductively after any sequence of blowings-up
whose centres have only normal crossings with respect to the exceptional
divisors and lie in the constant loci of $\inv_X(\cdot)$. The paper is
self-contained and includes detailed examples. One of our goals is that the
reader understand the desingularization theorem, rather than simply ``know'' it
is true.