Nonlinear effects of the gradient inhomogeneity of the magnetic field on the stochastic motion of charged particles due to an electrostatic wave propagated arbitarily relative to the magnetic field are considered in this paper. A sequence of canonical transformations is preformed to obtain a Hamiltonian explicitly exhibiting the possibility of the resonance between the periodic motion of particles and oscillation in the wave. The theoretical analysis shows that, due to the inhomogeneity of the magnetic field, the threshold for the onse of the stochasticity is changed and, in the case of weak inhomogeneity of the magnetic field, it is lowered, which means that the stochasticity appears more easily than in the case of uniform magnetic field.