We have designed and implemented a computer-controlled system that uses an adaptive control algorithm (generalized minimum variance) to buffer the breath-by-breath variations of the end-tidal CO2 fraction (FETCO2) that occur spontaneously or are exaggerated in certain experimental protocols (e.g., induced hypoxia, any type of induced variations in the ventilatory pattern). Near the end of each breath, FETCO2 of the following breath is predicted and the inspired CO2 fraction (FICO2) of the upcoming breath is adjusted to minimize the difference between the predicted and desired FETCO2 of the next breath. The one-breath-ahead prediction of FETCO2 is based on an adaptive autoregressive with exogenous inputs (ARX) model: FETCO2 of a given breath is related to FICO2, FETCO2 of the previous breath, and inspiratory ventilation. Adequacy of the prediction is demonstrated using data from experiments in which FICO2 was varied pseudorandomly in wakefulness and sleep. The algorithm for optimally buffering changes in FETCO2 is based on the coefficients of the ARX model. We have determined experimentally the frequency of FETCO2 variations that can be buffered adequately by our controller, testing both spontaneous variations in FETCO2 and variations induced by hypoxia in young awake human subjects. The controller is most effective in buffering variations of FETCO2 in the frequency range of <0.1 cycle/breath. Some potential applications are discussed.