  We analyze Ekeland's variational principle in the context of reverse
mathematics. We find that that the full variational principle is equivalent to
$\Pi^1_1$-${\sf CA}_0$, a strong theory of second-order arithmetic, while
natural restrictions (e.g.~to compact spaces or continuous functions) yield
statements equivalent to weak K\"onig's lemma (${\sf WKL}_0$) and to
arithmetical comprehension (${\sf ACA}_0$). We also find that the localized
version of Ekeland's variational principle is equivalent to $\Pi^1_1$-${\sf
CA}_0$ even when restricting to continuous functions. This is a rare example of
a statement about continuous functions having great logical strength.
