Transit observations in the Lyman-α line of the hot-Jupiters HD 209458b and HD 189733b revealed strong signatures of neutral hydrogen escaping the planets' upper atmospheres. Here we present a 3D particle model of the dynamics of the escaping atoms. This model is used to calculate theoretical Lyman-α absorption line profiles, which can be directly compared with the absorption observed in the blue wing of the line during the planets' transit. For HD 209458b, the observed velocities of the planet-escaping atoms up to −130 km s −1 are naturally explained by radiation-pressure acceleration. The observations are well-fitted with an ionizing flux of about 3−4 times the solar value and a hydrogen escape rate in the range 10 9 −10 11 g s −1 , in agreement with theoretical predictions. For HD 189733b, absorption by neutral hydrogen has been observed in September 2011 in the velocity range −230 to −140 km s −1 . These velocities are higher than for HD 209458b and require an additional acceleration mechanism for the escaping hydrogen atoms, which could be interactions with stellar wind protons. We constrain the stellar wind (temperature ∼3 × 10 4 K, velocity 200 ± 20 km s −1 and density in the range 10 3 −10 7 cm −3 ) as well as the escape rate (4 × 10 8 −10 11 g s −1 ) and ionizing flux (6−23 times the solar value). We also reveal the existence of an "escape-limited" saturation regime in which most of the gas escaping the planet interacts with the stellar protons. In this regime, which occurs at proton densities above ∼3 × 10 5 cm −3 , the amplitude of the absorption signature is limited by the escape rate and does not depend on the wind density. The non-detection of escaping hydrogen in earlier observations in April 2010 can be explained by the suppression of the stellar wind at that time, or an escape rate of about an order of magnitude lower than in 2011. For both planets, best-fit simulations show that the escaping atmosphere has the shape of a cometary tail. Simulations also revealed that the radiative blow-out of the gas causes spectro-temporal variability of the absorption profile as a function of time during and after the planetary transit. Because no such variations are observed when the absorbing hydrogen atoms are accelerated through interactions with the stellar wind, this may be used to distinguish between the two scenarios.