  We treat the problem of adiabatic losses and stochastic particle acceleration
in gamma-ray burst (GRB) blast waves that decelerate by sweeping up matter from
an external medium. The shocked fluid is assumed to be represented by a
homogeneous expanding shell. The energy lost by nonthermal particles through
adiabatic expansion is converted to the bulk kinetic energy of the outflow,
permitting the evolution of the bulk Lorentz factor Gamma of the blast wave to
be self-consistently calculated. The behavior of the system is shown to
reproduce the hydrodynamic self-similar solutions in the relativistic and
nonrelativistic limits, and the formalism is applicable to scenarios that are
intermediate between the adiabatic and fully radiative regimes. Nonthermal
particle energization through stochastic gyroresonant acceleration with
magnetic turbulence in the blast wave is treated by employing energy-gain rates
and diffusive escape timescales based upon expressions derived in the
quasilinear regime. If the magnetic field in the shocked fluid approaches its
equipartition value, this process can accelerate escaping particles to
>~10^{20} eV energies, consistent with the hypothesis that ultra-high energy
cosmic rays (UHECRs) are accelerated by GRB blast waves. Due to particle
trapping by the magnetic turbulence, only the highest energy particles can
escape during the prompt and afterglow phases of a GRB for acceleration by a
Kolmogorov spectrum of MHD turbulence. Lower energy particles begin to escape
as the blast wave becomes nonrelativistic and shock Fermi acceleration becomes
more important.
