A medical ventilator is provided for providing continuous, closed-loop control of the pressure of gas within a patient's mouth or respiratory tract in accordance with any selected pressure input waveform. The medical ventilator comprises an adaptive, feedback controller which provides independent control of the inspiratory and expiratory branches of the ventilator, while continuously controlling mouth pressure. The digital coefficients of the controller are updated to adjust for variations in the resistance of the patient's respiratory tract resulting from the magnitude of flow of inspiratory gas into the tract and patient-to-patient differences. Pressure in the expiratory branch is controlled by controlling, through a pressure-regulating valve, the magnitude of back pressure applied to a diaphragm valve. A venturi provides a reference pressure for the pressure-regulating valve below that of the surrounding atmosphere to enable application of a negative back pressure to the diaphragm valve.