A method for automatically controlling ventilation of a patient includes receiving a target expiratory CO2 concentration, measuring an actual expiratory CO2, and comparing the actual expiratory CO2 concentration to the target expiratory CO2. A ventilation rate for the patient is then calculated based on the comparison of the actual expiratory CO2 concentration and the target expiratory CO2 in order to maintain the actual expiratory CO2 within a predetermined range of the target expiratory CO2. The patient is then automatically ventilated based on the calculated ventilation rate.