  Let $G$ be an $n$-vertex triangle-free graph. The celebrated Mantel's theorem
showed that $e(G)\leq \lfloor\frac{n^2}{4}\rfloor$. In 1962, Erd\H{o}s
(together with Gallai), and independently Andr\'{a}sfai, proved that if $G$ is
non-bipartite then $e(G)\leq \lfloor\frac{(n-1)^2}{4}\rfloor+1$. In this paper,
we extend this result and show that if $G$ has chromatic number at least four
and $n\geq 150$, then $e(G)\leq \lfloor\frac{(n-3)^2}{4}\rfloor+5$. The blow-up
of Gr\"{o}tzsch graph shows that this bound is best possible.
