Lemma 75.34.3 (Zariski's Main Theorem). Let $S$ be a scheme. Let $f : X \to Y$ be a morphism of algebraic spaces over $S$. Assume $f$ is quasi-finite and separated and assume that $Y$ is quasi-compact and quasi-separated. Then there exists a factorization

$\xymatrix{ X \ar[rd]_ f \ar[rr]_ j & & T \ar[ld]^\pi \\ & Y & }$

where $j$ is a quasi-compact open immersion and $\pi$ is finite.

Proof. Let $X \to Y' \to Y$ be as in the conclusion of Lemma 75.34.2. By Limits of Spaces, Lemma 69.9.7 we can write $\nu _*\mathcal{O}_{Y'} = \mathop{\mathrm{colim}}\nolimits _{i \in I} \mathcal{A}_ i$ as a directed colimit of finite quasi-coherent $\mathcal{O}_ X$-algebras $\mathcal{A}_ i \subset \nu _*\mathcal{O}_{Y'}$. Then $\pi _ i : T_ i = \underline{\mathop{\mathrm{Spec}}}_ Y(\mathcal{A}_ i) \to Y$ is a finite morphism for each $i$. Note that the transition morphisms $T_{i'} \to T_ i$ are affine and that $Y' = \mathop{\mathrm{lim}}\nolimits T_ i$.

By Limits of Spaces, Lemma 69.5.7 there exists an $i$ and a quasi-compact open $U_ i \subset T_ i$ whose inverse image in $Y'$ equals $f'(X)$. For $i' \geq i$ let $U_{i'}$ be the inverse image of $U_ i$ in $T_{i'}$. Then $X \cong f'(X) = \mathop{\mathrm{lim}}\nolimits _{i' \geq i} U_{i'}$, see Limits of Spaces, Lemma 69.4.1. By Limits of Spaces, Lemma 69.5.12 we see that $X \to U_{i'}$ is a closed immersion for some $i' \geq i$. (In fact $X \cong U_{i'}$ for sufficiently large $i'$ but we don't need this.) Hence $X \to T_{i'}$ is an immersion. By Morphisms of Spaces, Lemma 66.12.6 we can factor this as $X \to T \to T_{i'}$ where the first arrow is an open immersion and the second a closed immersion. Thus we win. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).