The effective Hamiltonian describing the motion of an exciton in an externa
l nonhomogeneous magnetic field is derived. The magnetic field plays the ro
le of an effective potential for the exciton motion, which results in an in
crement bf the exciton mass, and modifies the exciton kinetic-energy operat
or. In contrast to the homogeneous field case, the exciton in a nonhomogene
ous magnetic field can also be trapped in the low-field region and the fiel
d gradient increases the exciton confinement. The trapping energy and wave
function of the exciton in a GaAs two-dimensional electron gas for specific
circular magnetic field configurations are calculated. The results show th
at excitons can be trapped by nonhomogeneous magnetic fields, and that the
trapping energy is strongly correlated with the shape and strength of the n
onhomogeneous magnetic field profile.