We show that the r-mode instability can generate strong toroidal fields in the core of accreting millisecond quark stars by inducing differential rotation. We follow the spin frequency evolution on a long time-scale, taking into account the magnetic damping rate in the evolution equations of r-modes. The maximum spin frequency of the star is only marginally lower than without the magnetic field. The late-time evolution of the stars that enter the r-mode instability region is instead quite different if the generated magnetic fields are taken into account: they leave the millisecond pulsar region and become radio pulsars.