In preterm infants receiving supplemental oxygen, manual control of the inspired oxygen fraction is often time-consuming and inappropriate. We developed a system for automatic oxygen control and hypothesized that this system is more effective than routine manual oxygen control in maintaining target arterial oxygen saturation levels. We performed a randomized controlled crossover clinical trial in 12 preterm infants receiving nasal continuous positive airway pressure and supplemental oxygen. Periods with automatic and routine manual oxygen control were compared with periods of optimal control by a fully dedicated person. The median (range) percentage of time with arterial oxygen saturation levels within target range (87-96%) was 81.7% (39.0-99.8) for routine manual oxygen control, 91.0% (41.4-99.3) for optimal control, and 90.5% (59.0-99.4) for automatic control (ANOVA: p = 0.01). Pairwise post hoc comparisons revealed a statistically significant difference between automatic and routine manual oxygen control (Dunnett's test: p = 0.02). The frequency of manual oxygen adjustments was lowest in automatic control (Friedman's test: p < 0.001). Automatic oxygen control may optimize oxygen administration to preterm infants receiving nasal continuous positive airway pressure and reduce nursing time spent with oxygen control.