Upon learning that all $p$-groups of order $p^5$ are metabelian I wanted to investigate the case of order $p^4$. A group $G$ is metabelian if $G'$, its commutator subgroup, is abelian; equivalently, $G$ is metabelian if and only if there is an abelian normal subgroup $A$ such that the quotient group $G/A$ is abelian.
A natural choice of abelian normal subgroup is the center, $Z(G)$. If $|G:Z(G)|=1$, $G$ is abelian and is therefore metabelian. $G$ is also abelian if $|G:Z(G)|=p$ because if $G/Z(G)$ is cyclic then $G$ is abelian. When $|G:Z(G)|=p^2$, $G/Z(G)$ is abelian and therefore $G$ is metabelian.
I haven't been able to work out the last case, where $|G:Z(G)|=p^3$ (i.e., $|Z(G)|=p$). I tried showing $G'$ is abelian by showing $G' \le Z(G)$ since we know $G'$, being normal in $G$, intersects the center nontrivially.
How can I finish this proof that all $p$-groups of order $p^4$ are metabelian, or is there a counterexample?