We study the dynamical evolution of the near-Earth Jupiter family comets (NEJFCs) that came close to or crossed the Earth's orbit at the epoch of their discovery (perihelion distances q disc < 1.3 AU). We found a minimum in the time evolution of the mean perihelion distanceq of the NEJFCs at the discovery time of each comet (taken as t = 0) and a past-future asymmetry ofq in an interval -1000 yr, +1000 yr centred on t = 0, confirming previous results. The asymmetry indicates that there are more comets with greater q in the past than in the future. For comparison purposes, we also analysed the population of near-Earth asteroids in cometary orbits (defined as those with aphelion distances Q > 4.5 AU) and with absolute magnitudes H < 18. We found some remarkable differences in the dynamical evolution of both populations that argue against a common origin. To further analyse the dynamical evolution of NEJFCs, we integrated in time a large sample of fictitious comets, cloned from the observed NEJFCs, over a 20 000 yr time interval and started the integration before the comet's discovery time, when it had a perihelion distance q > 2 AU. By assuming that NEJFCs are mostly discovered when they decrease their perihelion distances below a certain threshold q thre = 1.05 AU for the first time during their evolution, we were able to reproduce the main features of the observedq evolution in the interval [-1000, 1000] yr with respect to the discovery time. Our best fits indicate that ∼40% of the population of NEJFCs would be composed of young, fresh comets that entered the region q < 2 AU a few hundred years before decreasing their perihelion distances below q thre , while ∼60% would be composed of older, more evolved comets, discovered after spending at least ∼3000 yr in the q < 2 AU region before their perihelion distances drop below q thre . As a byproduct, we put some constraints on the physical lifetime τ phys of NEJFCs in the q < 2 AU region. We found a lower limit of a few hundreds of revolutions and an upper limit of about 10 000-12 000 yr, or about 1600-2000 revolutions, somewhat longer than some previous estimates. These constraints are consistent with other estimates of τ phys , based either on mass loss (sublimation, outbursts, splittings) or on the extinction rate of Jupiter family comets (JFCs).