Suppose that $p\mid a$. Since $a\mid b^2$, it follows that $p\mid b^2$. Then, it follows that $p\mid b$. This, however, is impossible since $a$ and $b$ are relatively prime. Therefore, there can be no primes dividing $a$. Therefore, $a=\pm 1$. Since $\pm 1$ divides everything, $a\mid b$ (and $b$ can be any integer).
The proof of if $p\mid b^2$ then $p\mid b$ is the same as the proof that if $2\mid b^2$, then $2\mid b$ (this shows up in the contradiction proof of $\sqrt{2}$ being irrational).
In this case, the proof that if $p\mid b^2$ then $p\mid b$ requires unique factorization. If we prime factorize $b^2$, then since $p\mid b^2$, $p$ must be one of the prime factors of $b^2$. However, since the prime factors of $b^2$ are just the prime factors of $b$ with twice their multiplicity, it follows that $p$ must be a prime factor of $b$ and so $p\mid b$. (Or see the alternative proof in the comments below).