Inhomogeneous magnetic fields are used to exert a magnetic force on two-dimensional excitons. The large field gradients are produced by positioning a thin magnetized stripe of dysprosium on top of a semi-magnetic CdMnTe/CdMgTe quantum well. By measuring the photoluminescence energy and intensity, spatially resolved with mm resolution, the actual value of the local magnetic force, which can be as high as 0.4 meV/mm, and its effect on the exciton motion are determined.Introduction Spatially inhomogeneous magnetic fields have been frequently used to control the motion of electrically neutral physical systems, like atoms and molecules. One important example is the use of a magnetic trap to confine atomic gases to a limited region of space, which recently has permitted the observation of Bose-Einstein condensation [1]. The underlying trapping mechanism stems from the fact that in a given magnetic field gradient rB an object with a certain magnetic moment m, experiences a magnetic force F given by F mrB. Recently it has been shown that this magnetic force even can be used to trap diamagnetic biological tissue, including living creatures as frogs or grasshoppers [2], or ferromagnetic objects [3].Inspired by these studies we want to explore the possibility to magnetically confine excitons in semiconductor heterostructures. Therefore we study the effect of the magnetic force on two-dimensional (2D) particles in a semiconductor quantum well (QW), where the thin layer restricts the longitudinal and the magnetic force the lateral movement. In a nonmagnetic QW all particles, i.e. electrons, holes and bound electron±hole pairs (excitons), exhibit a diamagnetic response to an external magnetic field, which means that they all are driven to the same region of space where the field is lowest. In this sense using magnetic forces to spatially confine excitons is fundamentally different from its electrostatic counterpart [4], where the electric force is opposite for electrons and holes, driving them apart. In order to realize the field gradients strong enough to control the motion of excitons it is necessary to vary the field considerably (few Tesla) on a distance comparable to the typical exciton diffusion lengths (few mm).In this paper we demonstrate how to produce such field gradients by positioning a thin magnetized dysprosium (Dy) stripe directly on top of a QW, and how to measure this gradient and its effect on the exciton motion by using spatially resolved photoluminescence (PL) and PL-excitation (PLE) spectroscopy.