International audienceA one-dimensional chemistry model is applied to study the stable hydrogen (D) and stable oxygen isotope (17O, 18O) composition of water vapour in stratosphere and mesosphere. The stable isotope ratios of tropospheric H2O are determined by "physical'' fractionation effects, i.e. phase changes, diffusion processes, and mixing of air masses. Due to these processes water vapour entering the stratosphere (i) is mass-dependently fractionated (MDF), i.e. shifts in the isotope ratio 17O/16O are ~0.52 times of those of 18O/16O and (ii) shows isotope shifts in D/H, which are ~5 times of those in 18O/16O. In stratosphere and mesosphere "chemical'' fractionation, that are the oxidation of methane, re-cycling of H2O via the HOx family, and isotope exchange reactions are shown to considerably enhance the isotope ratios in the imported tropospheric H2O. Enrichments relative to the isotope ratios at the tropopause are used to derive the partitioning of tropospheric (unmodified), re-cycled and in situ generated H2O. The model reasonably predicts overall increases of the stable isotope ratios in H2O by ~23% for D/H, ~8.5% for 17O/16O, and ~14% for 18O/16O. The17O/16O and 18O/16O ratios in H2O are shown to be a measure of the partitioning of HOx that receives its O atom either from the reservoirs O2 or O3. In the entire middle atmosphere, MDF O2 is the major donator of oxygen atoms incorporated in OH and HO2 and thus in H2O. It is demonstrated that in the stratosphere mass-independent fractionation (MIF) in O3 in a first step is transferred to the NOx family and only in a second step to HOx and H2O. In contrast to CO2, O(1D) only plays a minor role in this MIF transfer. The major uncertainty in our calculation arises from the many badly quantified isotope exchange reactions and kinetic isotope fractionation factors