We provide an exhaustive spectral analysis of the two-dimensional periodic square graph lattice with a magnetic field. We show that the spectrum consists of the Dirichlet eigenvalues of the edges and of the preimage of the spectrum of a certain discrete operator under the discriminant (Lyapunov function) of a suitable Kronig-Penney Hamiltonian. In particular, between any two Dirichlet eigenvalues the spectrum is a Cantor set for an irrational flux, and is absolutely continuous and has a band structure for a rational flux. The Dirichlet eigenvalues can be isolated or embedded, subject to the choice of parameters. Conditions for both possibilities are given. We show that generically there are infinitely many gaps in the spectrum, and the Bethe-Sommerfeld conjecture fails in this case.