The Whitehead problem is solved in the class of toral relatively hyperbolic groups G (i.e. torsion-free relatively hyperbolic groups with abelian parabolic subgroups): there is an algorithm which, given two finite tuples (u1,..., un) and (v1,..., vn) of elements of G, decides whether there is an automorphism of G taking ui to vi for all i.