A case study was conducted in a desert–oasis ecotone in the middle of China's Heihe River basin to reveal the response of sap velocity to environmental variables. We measured sap flow in the branches and stems of desert shrubs (Nitraria sphaerocarpa and Elaeagnus angustifolia) using sap-flow gauges, and simultaneously measured environmental variables at the study site. The relationships between sap velocity and the environmental variables were analysed using redundancy analysis. The diurnal variation in sap velocity was best described by a bimodal curve, except for the branches of N. sphaerocarpa, which followed a unimodal curve. Sap flow began about 1 h earlier in the branches than in the stems. The dynamic variations in sap velocity were remarkably similar for the two species at a given position (stem vs branch) but differed between the two positions for each species. Redundancy analysis and Kendall's tau analysis indicated that precipitation had the greatest influence on sap velocity in the stem, whereas precipitation duration significantly affected sap velocity in the branches of the desert shrubs (R2 = 0·85 and 0·73, respectively). The variation in sap velocity could be described by a multiple linear regression against the meteorological variables, and the simulated value was significantly linearly correlated with the measured value (0·861 ≤ R2 ≤ 0·938, P < 0·0001). Copyright © 2010 John Wiley & Sons, Ltd.