The phase, as well as the magnitude, of MRI images can carry useful information. It may be used to encode flow or temperature, or to map the magnetic field for the undistorting of EPIs and automated shimming. In all cases, we measure the extra spin given to nuclei. Unfortunately, we can only measure the final phase of the spins: the rotation is wrapped into the range [-pi, +pi], and to obtain a measure of the parameter of interest the missing multiples of 2pi must be replaced--a process known as phase unwrapping. While simple in principle, standard phase unwrapping algorithms fail catastrophically in the presence of even small amounts of noise. Here we present a new algorithm for robust three-dimensional phase unwrapping, in which unwrapping is guided, so that it initially works on less noisy regions. We test the algorithm on simulated phase data, and on maps of magnetic field, which were then used to successfully undistort EPI images. The unwrapping algorithm could be directly applied to other kinds of phase data.