  Two central topics of study in combinatorics are the so-called evolution of
random graphs, introduced by the seminal work of Erd\H{o}s and R\'enyi, and the
family of $H$-free graphs, that is, graphs which do not contain a subgraph
isomorphic to a given (usually small) graph $H$. A widely studied problem that
lies at the interface of these two areas is that of determining how the
structure of a typical $H$-free graph with $n$ vertices and $m$ edges changes
as $m$ grows from $0$ to $\text{ex}(n,H)$. In this paper, we resolve this
problem in the case when $H$ is a clique, extending a classical result of
Kolaitis, Pr\"omel, and Rothschild. In particular, we prove that for every $r
\ge 2$, there is an explicit constant $\theta_r$ such that, letting $m_r =
\theta_r n^{2-\frac{2}{r+2}} (\log n)^{1/\left[\binom{r+1}{2}-1\right]}$, the
following holds for every positive constant $\varepsilon$. If $m \ge
(1+\varepsilon) m_r$, then almost all $K_{r+1}$-free $n$-vertex graphs with $m$
edges are $r$-partite, whereas if $n \ll m \le (1-\varepsilon)m_r$, then almost
all of them are not $r$-partite.
