The magnetic fields of spiral galaxies are so strong that they cannot be primordial. Their typical values are over one billion times higher than any value predicted for the early Universe. Explaining this immense growth and incorporating it in galaxy evolution theories is one of the long-standing challenges in astrophysics. So far, the most successful theory for the sustained growth of the galactic magnetic field is the alpha-omega dynamo. This theory predicts a characteristic dipolar or quadrupolar morphology for the galactic magnetic field, which has been observed in external galaxies. However, so far, there has been no direct demonstration of a mean-field dynamo operating in direct, multi-physics simulations of spiral galaxies. We do so in this work. We employ numerical models of isolated, star-forming spiral galaxies that include a magnetized gaseous disk, a dark matter halo, stars, and stellar feedback. Naturally, the resulting magnetic field has a complex morphology that includes a strong random component. Using a smoothing of the magnetic field on small scales, we are able to separate the mean from the turbulent component and analyze them individually. We find that a mean-field dynamo naturally occurs as a result of the dynamical evolution of the galaxy and amplifies the magnetic field by an order of magnitude over half a Gyr. Despite the highly dynamical nature of these models, the morphology of the mean component of the field is identical to analytical predictions. This result underlines the importance of the mean-field dynamo in galactic evolution. Moreover, by demonstrating the natural growth of the magnetic field in a complex galactic environment, it brings us a step closer to understanding the cosmic origin of magnetic fields.