Due to magnetic field inhomogeneities, EPI images are geometrically distorted, predominantly along the phase-encoding direction. Currently, the distortion is either ignored or compensated manually using a warping function defined through a set of landmarks. We propose an automatic method to unwarp the geometric distortion of EPI images by registering them with corresponding undistorted anatomical MRI images. We show that cubic splines are optimal interpolating functions for both landmark interpolation and approximation. We will consequently use the same warping space in our algorithm which replaces landmarks by an image difference criterion. B-splines are used as generating functions, which leads to a fast and accurate computation. Multiresolution gives robustness and additional speedup. The algorithm performance was evaluated using both real and synthetic data and was found superior to the manual method.