We review spacetime dynamics in the presence of large-scale electromagnetic fields and then consider the effects of the magnetic component on perturbations to a spatially homogeneous and isotropic universe. Using covariant techniques, we refine and extend earlier work and provide the magnetohydrodynamic equations that describe inhomogeneous magnetic cosmologies in full general relativity. Specialising this system to perturbed Friedmann–Robertson–Walker models, we examine the effects of the field on the expansion dynamics and on the growth of density inhomogeneities, including non-adiabatic modes. We look at scalar perturbations and obtain analytic solutions for their linear evolution in the radiation, dust and inflationary eras. In the dust case we also calculate the magnetic analogue of the Jeans length. We then consider the evolution of vector perturbations and find that the magnetic presence generally reduces the decay rate of these distortions. Finally, we examine the implications of magnetic fields for the evolution of cosmological gravitational waves.