Yes, this must be the case.
Two tools are needed for the proof: the Poincaré duality theorem for compactly supported cohomology; and group cohomology.
Let $m = \text{dim}(M)$. The universal cover $\tilde M$ is a contractible $m$-manifold, and so by the above version of Poincaré duality its compactly supported cohomology satisfies
$$H^i_c(\tilde M;\mathbb Z) \approx \begin{cases}
\mathbb Z & \quad\text{if $i=m$} \\
0 &\quad\text{if $i \ne m$}
\end{cases}
$$
The relation to group cohomology is the isomorphism
$$H^i_c(\tilde M;\mathbb Z) \approx H^i(\pi_1 M;\mathbb Z (\pi_1 M))
$$
where the right hand side is cohomology with group ring coefficients, twisted by the action of $\pi_1 M$ on its group ring. You can find this, for example, in Brown's book "Cohomology of Groups" (assuming that $M$ is a CW complex, which covers tremendously many cases, including the smooth case; I'm unsure of a reference without that assumption).
But then a simple calculation shows that
$$H^i(\mathbb Z^n;\mathbb Z (\mathbb Z^n)) \approx \begin{cases}
\mathbb Z &\quad\text{if $i=n$} \\
0 &\quad\text{if $i \ne n$}
\end{cases}
$$
and therefore $m=n$.