THE origin of galactic magnetic fields has been a long-standing puzzle. Models based on standard dynamo theory1–4 encounter several problems, the most fundamental of which is that, in order to explain the strengths of observed large-scale magnetic fields5–7, the fluctuating magnetic fields in galaxies must be unreasonably large8–12: the energy density in these small-scale fields must far exceed the local kinetic energy density. Here we propose an alternative mechanism of magnetic-field generation in galaxies. We show that a seed field can be generated by the rotation of an aspherical cloud of ionized gas around a central massive black hole. Strong shear flows in the rotating gas amplify this seed field, and a relatively slow galactic wind can transport the field to the outer regions of a galaxy in about 100 million years—a timescale short enough to meet the constraints imposed by the observation of strong fields in very young galaxies13,14.