The generation of a magnetic field in the Early Universe is considered, due to the gravitational production of the Z-boson field during inflation. Scaled to the epoch of galaxy formation this magnetic field suffices to trigger the galactic dynamo and explain the observed galactic magnetic fields. The mechanism is independent of the inflationary model.