Nonlinear dynamics of electrons accelerated by resonant fields in nonuniform plasmas