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 non-linear dynamo. Recent numerical work has shown that a large-scale magnetic field, which is predominantly azimuthal, axisymmetric and has zero net flux, 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. In the limit of small vertical wavelengths, we show that magnetorotational shearing waves have the form of vertically localized wavepackets that follow the classical MRI dispersion relation to a first approximation. We determine analytically the spatiotemporal evolution of these wavepackets and calculate the associated mean electromotive force (EMF), which results from the correlation of the velocity and magnetic field perturbations. The vertical structure of the azimuthal field results in a radial EMF that 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. We compare these findings with numerical solutions of the linearized equations in various approximations, and show them to be compatible with recent non-linear simulations of a MRI dynamo.