We show that Einstein's main equations for stationary axisymmetric fields in vacuum are equivalent to the motion equations for bosonic strings moving on a special nonflat background. This new representation is based on the analysis of generalized harmonic maps in which the metric of the target space explicitly depends on the parametrization of the base space. It is shown that this representation is valid for any gravitational field which possesses two commuting Killing vector fields. We introduce the concept of dimensional extension which allows us to consider this type of gravitational fields as strings embedded in D-dimensional nonflat backgrounds, even in the limiting case where the Killing vector fields are hypersurface orthogonal.