We analyze the mechanism of magnetic polarity reversals in a three- dimensional numerical dynamo model. A dynamo driven by compositional convection in a rotating spherical fluid shell with a solid, electrically conducting inner core exhibits regular reversals of its dominantly axial dipole magnetic field at Rayleigh number Ra = 300, Ekman number E = 0.01, Prandtl number Pr = 1 and Roberts number q = 20. The fluid motions that sustain the field include (1) azimuthal jets which generate toroidal magnetic field; (2) high-latitude, helical convective plumes which generate poloidal magnetic field; and (3) meridional circulation which transports the magnetic field. Inverse poloidal field is produced locally in the convective plumes. Outcrops of reversed field create inverse magnetic flux spots on the core-mantle boundary above the plumes that are precursors to the reversal. The dipole polarity change as seen from the surface occurs when the reversed magnetic flux is distributed over the core-mantle boundary by the meridional circulation. In our model, the reversed flux is transported from south to north and the transitional field has a strong quadrupole component. The duration of the dipole transition is the meridional transport time, and corresponds to a few thousand years in the Earth's core. The duration of the stable polarity epochs depends on several effects, including the strengths of the sources of normal and reversed poloidal field in the plumes, flux transport, and flux diffusion. Comparable reversal periods are found in an equivalent kinematic dynamo model with steady velocities and without Lorentz forces, confirming that these reversals are not triggered by changes in the flow and are primarily magnetic induction effects.