(Abriged) The magnetorotational instability (MRI) is believed to be an efficient way to transport angular momentum in accretion discs. It has also been suggested as a way to amplify magnetic fields in discs, the instability acting as a nonlinear dynamo. Recent numerical work has shown that a large-scale magnetic field, which is predominantly azimuthal, can be sustained by motions driven by the MRI of this same field. Following this idea, we present an analytical calculation of the MRI in the presence of an azimuthal field with a non-trivial vertical structure. We find that the mean radial EMF associated to MRI modes tends to reduce the magnetic energy, acting like a turbulent resistivity by mixing the non-uniform azimuthal field. Meanwhile, the azimuthal EMF generates a radial field that, in combination with the Keplerian shear, tends to amplify the azimuthal field and can therefore assist in the dynamo process. This effect, however, is reversed for sufficiently strong azimuthal fields, naturally leading to a saturation of the dynamo and possibly to a cyclic behaviour of the magnetic field, as found in previous numerical works.