The global carbon and water cycles are strongly governed by the simultaneous diffusion of CO2 and water vapour through the leaves of terrestrial plants. These diffusive fluxes are controlled by plantstextquoteright adaptations to balance carbon gains and hydraulic risks. We introduce a trait-based optimality theory that unifies the treatment of stomatal responses and biochemical acclimation of plants to changing environments. Tested with experimental data from eighteen species, our model successfully predicts the simultaneous decline in carbon assimilation rate, stomatal conductance, and photosynthetic capacity during progressive soil drought. It also correctly predicts the dependencies of gas exchange on atmospheric vapour pressure deficit, temperature, and CO2. Consistent with widely observed patterns, inferred trait values for the analysed species display a spectrum of stomatal strategies, a safety-efficiency trade-off, and a convergence towards low hydraulic safety margins. Our unifying theory opens new avenues for reliably modelling the interactive effects of drying soil and air and rising atmospheric CO2 on global photosynthesis and transpiration.Competing Interest StatementThe authors have declared no competing interest.