The band structure theory of magnetism in 3d-4f compounds is reviewed. Among the open-shell electrons, a hierarchy of interactions is present which governs the intrinsic magnetic properties of these materials. Density functional theory (DFT) is an appropriate tool to describe and quantitatively investigate both ground state properties and model interaction parameters, which are necessary to calculate the temperature-dependent behaviour. The cornerstones of the DFT are explicitly sketched, as well as recent developments needed to cope with the treatment of localized 4f and itinerant 3d magnetism in one and the same framework. This includes the open-core scheme, self-interaction corrected DFT, relativistic DFT, and orbital polarization. On this basis, the exchange coupling among itinerant and localized states can be understood, together with the size of Curie temperature and ground state spin and orbital magnetic moments. Finally, the problem of magnetocrystalline anisotropy is addressed, concerning both the band and the 4f crystal field contribution.