A method and apparatus for providing ventilatory assistance to a spontaneously breathing patient an error signal (56) is computed that is the difference between a function of respiratory airflow (54) over a period of time and a target value (52). Using a servo loop, air is delivered to the patient at a pressure that is a function of the error signal, the phase of the current breathing cycle, and a loop gain that varies depending on the magnitude of the error signal. The loop gain increases with the magnitude of the error signal, and the gain is greater for error signals below a ventilation target than for error signals above the ventilation target value. The target value (52) is an alveolar ventilation that takes into account the patient's physiologic dead space.