The dynamics of gamma-ray burst jets during the afterglow phase have an important effect on the interpretation of their observations and for inferring key physical parameters such as their true energy and event rate. Semi-analytic models generally predict a fast lateral expansion, where the jet opening angle asymptotically grows exponentially with its radius. Numerical simulations, however, show a much more modest lateral expansion, where the jet retains memory of its initial opening angle for a very long time, and the flow remains non-spherical until it becomes subrelativistic, and only then gradually approaches spherical symmetry. Here we suggest a new analytic model based on a new physically derived recipe for the lateral expansion. We also generalize the model by relaxing the common approximations of ultrarelativistic motion and a narrow jet opening angle. We find that the new analytic model fits much better the results of numerical simulations, mainly because it remains valid also in the mildly relativistic, quasi-spherical regime. This model shows that for modest initial jet half-opening angles, xsθ0, the outflow is not sufficiently ultrarelativistic when its Lorentz factor reaches Γ= 1/θ0 and therefore the sideways expansion is rather slow, showing no rapid, exponential phase. On the other hand, we find that jets with an extremely narrow initial half-opening angle, of about θ0≪ 10−1.5 or so, which are still sufficiently ultrarelativistic at Γ= 1/θ0, do show a phase of rapid, exponential lateral expansion. However, even such jets that expand sideways exponentially are still not spherical when they become subrelativistic.