We report on the realization and characterization of a system for the simultaneous stabilization and control of magnetic field strength and gradient in a region of 35 mm and along a given direction. The system is based on two magnetometers, each providing a field readout every 10 s, and a control unit, which real-time processes the readouts and controls the currents flowing into two compensation coils. Attenuations of 30 dB for the field strength and 20 dB for the gradient have been achieved, along with feedback loop bandwidths of 450 and 620 Hz, respectively. The method can be extended in order to noninvasively control the field strength and gradient along all three directions as well as higher-order multipole terms.