FINAL EDIT : This edit cleans up the first proof (and simplifies it -- there are no longer any references to the free nilpotent group) and adds some remarks to the second proof following the discussion in the comments.

PROOF 1.

Here's a low-tech way to see that a surface group is not free (though cohomology is secretly lurking in the background). Let $G_g = \langle a_1,b_1,\ldots,a_g,b_g\ |\ [a_1,b_1]\cdots [a_g,b_g]=1 \rangle$ be the surface group. Form the group

$$\tilde{G}_g = \langle a_1,b_1,\ldots,a_g,b_g,t\ |\ [a_1,b_1]\cdots [a_g,b_g]=t, [a_i,t]=1, [b_i,t]=1\ \text{for all $1 \leq i \leq g$} \rangle$$

The subgroup of $\tilde{G}_g$ generated by $t$ is contained in the center and the quotient is $G_g$. Below I will show that this subgroup is infinite cyclic. We thus have a central extension

$$1 \longrightarrow \mathbb{Z} \longrightarrow \tilde{G}_g \longrightarrow G_g \longrightarrow 1.$$

If $G_g$ were free, then this would split as a direct product. However, since $t$ becomes zero when we abelianize $\tilde{G}$, there is no splitting homomorphism $\tilde{G}_g \rightarrow \mathbb{Z}$. Thus $G_g$ cannot be free.

It remains to show that the subgroup generated by $t$ is infinite cyclic. Let $H$ be the $3$-dimensional Heisenberg group, ie the group of upper-triangular $3 \times 3$ integer matrices with $1$'s on the diagonal. As is well-known, $H$ has a presentation
$$H = \langle x,y,z\ |\ [x,y]=z, [x,z]=1, [y,z]=1 \rangle.$$
Examining the presentations, there is a homomorphism $\psi : \tilde{G}_g \rightarrow H$ with

$$\psi(a_1) = x \quad \text{and} \quad \psi(b_1) = y \quad \text{and} \quad \psi(t) = z$$

and

$$\psi(a_i) = \psi(b_i) = 1 \quad \quad (2 \leq i \leq g)$$

Since $z$ generates an infinite cyclic subgroup of $H$ (as a matrix, $z$ is the matrix with $1$'s on the diagonal and at position $(1,3)$ and $0$'s elsewhere), it follows that $t$ generates an infinite cyclic subgroup of $\tilde{G}_g$.

PROOF 2.

It is known that free groups are Hopfian, i.e. that all surjections from a free group to itself are isomorphisms. A simple-minded cancellation-based proof (using Nielsen reduction) can be found in Proposition 2.7 of Lyndon and Schupp's book "Combinatorial group theory". Alternatively, Malcev proved that all residually finite groups are Hopfian (this can also be found in Lyndon and Schupp), and there are many proofs that free groups are residually finite; see the answers to the question Why are free groups residually finite?

This implies that if $F$ is a free group on $n$ generators and $S$ is a generating set for $F$ which has $n$ elements, then $S$ is a free generating set. But this implies the result -- letting $G_g$ be the surface group as above, by abelianizing we see that if $G_g$ were a free group, then it would be free on $2g$ generators. But $a_1,b_1,\ldots,a_g,b_g$ is a generating set of size $2g$ which is **not** free since it satisfies a relation. Thus $G_g$ is not free.