The dynamics of gamma-ray burst (GRB) jets during the afterglow phase is most reliably and accurately modeled using hydrodynamic simulations. All published simulations so far, however, have considered only a uniform external medium, while a stratified external medium is expected around long duration GRB progenitors. Here, we present simulations of the dynamics of GRB jets and the resulting afterglow emission for both uniform and stratified external media with rho(ext) alpha r(-k) for k = 0, 1, 2. The simulations are performed in two dimensions using the special relativistic version of the Mezcal code. Common to all calculations is the initiation of the GRB jet as a conical wedge of half-opening angle theta(0) = 0.2 whose radial profile is taken from the self-similar Blandford-McKee solution. The dynamics for stratified external media (k = 1, 2) are broadly similar to those derived for expansion into a uniform external medium (k = 0). The jet half-opening angle is observed to start increasing logarithmically with time (or radius) once the Lorentz factor G drops below theta(-1)(0). For larger k values, however, the lateral expansion is faster at early times (when Gamma >theta(-1)(0)) and slower at late times with the jet expansion becoming Newtonian and slowly approaching spherical symmetry over progressively longer timescales. We find that, contrary to analytic expectations, there is a reasonably sharp jet break in the light curve for k = 2 (a wind-like external medium), although the shape of the break is affected more by the viewing angle (for theta(obs) <= theta(0)) than by the slope of the external density profile (for 0 <= k <= 2). Steeper density profiles (i.e., increasing k values) are found to produce more gradual jet breaks while larger viewing angles cause smoother and later appearing jet breaks. The counterjet becomes visible as it becomes sub-relativistic, and for k = 0 this results in a clear bump-like feature in the light curve. However, for larger k values the jet decelerates more gradually, causing only a mild flattening in the radio light curve that might be hard to discern when k = 2. Late-time radio calorimetry, which makes use of a spherical flow approximation near the non-relativistic transition, is likely to consistently overestimate the true energy by up to a factor of a few for k = 2, but likely to either overpredict or underpredict it by a smaller factor for k = 0, 1.