We have studied a system consisting of a superconducting Al strip placed close to a perpendicularly magnetized Co/Pd rectangle. The stray fields of the rectangle produce a nonhomogeneous magnetic field in the superconductor. These stray fields can efficiently compensate the self-field inside the current-carrying superconductor. We have observed a current-polarity dependence of the critical current. The compensation effects are strongly dependent on the current in the superconductor and also on the temperature. The studied configuration is easily tunable for a large range of applied currents. (c) 2006 American Institute of Physics.