We demonstrate that a two-dimensional (2D) optical lattice loaded with repulsive, contact-interacting fermions shows a rich and systematic magnetic phase diagram. Trapping a few (N ≤ 12) fermions in each of the single-site minima of the optical lattice, we find that the shell structure in these quantum wells determines the magnetism. In a shallow lattice, the tunnelling between the single wells is strong, and the lattice is non-magnetic (NM). For deeper lattices, however, the shell filling of the single wells with fermionic atoms determines the magnetism. As a consequence of Hund's first rule, the interaction energy is lowered by maximizing the number of atoms of the same species. This leads to a systematic sequence of NM, ferromagnetic (F) and antiferromagnetic (AF) phases.