Suppose $x$ is a local maximum for $f$ and let $y \in \mathbb R$ ; assume $f(y) \ge f(x)$. Since $x$ is a local maximum, there exists $\delta > 0$ such that $f : ]x-\delta,x+\delta[ \to \mathbb R$ has its maximum at $x$. The function $f$ restricted to $]x-\delta,x[$ cannot be constant, otherwise it would have other extrema. Therefore there exists $x' \in ]x-\delta,x[$ with $f(x') < f(x)$ (and also in $]x,x+\delta[$, but this case is symmetric).
Now assume furthermore that $y < x-\delta$. Since $y<x'<x$ and $f(y) \ge f(x) > f(x')$, the function $f : [y,x] \to \mathbb R$ is continuous on a compact domain, so it attains its minimum ; it is not attained at $y$ or at $x$ (because the minimum is at most $f(x')$), so the minimum lies in $]y,x[$ ; this minimum is therefore a local minimum , i.e. an extremum point. This point was not supposed to exist, a contradiction.
Therefore $f(y) < f(x)$. Since $\delta$ can always be picked arbitrarily small, this trick works for all $y < x$ ; repeat in a symmetric way for $y > x$. Then $f(y) < f(x)$ for all $y \in \mathbb R \backslash \{x\}$, hence we are done.
Hope that helps,