When performing precision measurements, the quantity being measured is often perturbed by the measurement process itself. Such measurements include precision frequency measurements for atomic clock applications carried out with Ramsey spectroscopy. With the aim of eliminating probe-induced perturbations, a method of generalized autobalanced Ramsey spectroscopy (GABRS) is presented and rigorously substantiated. The usual local-oscillator frequency control loop is augmented with a second control loop derived from secondary Ramsey sequences interspersed with the primary sequences and with a different Ramsey period. This second loop feeds back to a secondary clock variable and ultimately compensates for the perturbation of the clock frequency caused by the measurements in the first loop. We show that such a two-loop scheme can lead to perfect compensation for measurement-induced light shifts and does not suffer from the effects of relaxation, time-dependent pulse fluctuations and phase-jump modulation errors that are typical of other hyper-Ramsey schemes. Several variants of GABRS are explored based on different secondary variables including added relative phase shifts between Ramsey pulses, external frequency-step compensation, and variable second-pulse duration. We demonstrate that a universal antisymmetric error signal, and hence perfect compensation at a finite modulation amplitude, is generated only if an additional frequency step applied during both Ramsey pulses is used as the concomitant variable parameter. This universal technique can be applied to the fields of atomic clocks, high-resolution molecular spectroscopy, magnetically induced and two-photon probing schemes, Ramsey-type mass spectrometry, and the field of precision measurements. Some variants of GABRS can also be applied for rf atomic clocks using coherent-population-trapping-based Ramsey spectroscopy of the two-photon dark resonance.