The sensitivity of quantum magnetometer is challenged by control errors and, especially in the solid state, by their short coherence times. Refocusing techniques can overcome these limitations and improve the sensitivity to periodic fields, but they come at the cost of reduced bandwidth and cannot be applied to sense static or aperiodic fields. Here we experimentally demonstrate that continuous driving of the sensor spin by a composite pulse known as rotary-echo yields a flexible magnetometry scheme, mitigating both driving power imperfections and decoherence. A suitable choice of rotary-echo parameters compensates for different scenarios of noise strength and origin. The method can be applied to nanoscale sensing in variable environments or to realize noise spectroscopy. In a room-temperature implementation, based on a single electronic spin in diamond, composite-pulse magnetometry provides a tunable trade-off between sensitivities in the μTHz(-1/2) range, comparable with those obtained with Ramsey spectroscopy, and coherence times approaching T(1).