  Let $V$ be a quasi-projective algebraic variety over a non-archimedean valued
field. We introduce topological methods into the model theory of valued fields,
define an analogue $\hat {V}$ of the Berkovich analytification $V^{an}$ of $V$,
and deduce several new results on Berkovich spaces from it. In particular we
show that $V^{an}$ retracts to a finite simplicial complex and is locally
contractible, without any smoothness assumption on $V$. When $V$ varies in an
algebraic family, we show that the homotopy type of $V^{an}$ takes only a
finite number of values. The space $\hat {V}$ is obtained by defining a
topology on the pro-definable set of stably dominated types on $V$. The key
result is the construction of a pro-definable strong retraction of $\hat {V}$
to an o-minimal subspace, the skeleton, definably homeomorphic to a space
definable over the value group with its piecewise linear structure.
