In this paper, the effect of a stationary inhomogeneous magnetic field on the electron acceleration by a high intensity Gaussian laser pulse is investigated. A focused TEM (0,0) laser mode with linear polarization in the transverse x-direction that propagates along the z-axis is considered. The magnetic field is assumed to be stationary in time, but varies longitudinally in space. A linear spatial profile for the magnetic field is adopted. In other words, the axial magnetic field increases linearly in the zdirection up to an optimum point z m and then becomes constant with magnitude equal to that at z m . Three-dimensional single-particle simulations are performed to find the energy and trajectory of the electron. The electron rotates around and stays near the z-axis. It is shown that with a proper choice of the magnetic field parameters, the electron will be trapped at the focus of the laser pulse. Because of the cyclotron resonance, the electron receives enough energy from the laser fields to be accelerated to relativistic energies. Using numerical simulations, the criteria for optimum regime of the acceleration mechanism is found. With the optimized parameters, an electron initially at rest located at the origin achieves final energy of c ¼ 802. The dynamics of a distribution of off-axis electrons are also investigated in which shows that high energy electrons with small energy and spatial spread can be obtained. V C 2015 AIP Publishing LLC. [http://dx.