  We study the effects of a magnetic impurity on the behavior of a $S=1/2$ spin
chain. At T=0, both with and without an applied uniform magnetic field, an
oscillating magnetization appears, whose decay with the distance from the
impurity is ruled by a power law. As a consequence, pairwise entanglement is
either enhanced or quenched, depending on the distance of the spin pair with
respect to the impurity and on the values of the magnetic field and the
intensity of the impurity itself. This leads us to suggest that acting on such
control parameters, an adiabatic manipulation of the entanglement distribution
can be performed. The robustness of our results against temperature is checked,
and suggestions about possible experimental applications are put forward.
