Diffusion-weighted magnetic resonance imaging is a key investigation technique in modern neuroscience. In clinical settings, diffusion-weighted imaging and its extension to diffusion tensor imaging (DTI) are usually performed applying the technique of echo-planar imaging (EPI). EPI is the commonly available ultrafast acquisition technique for single-shot acquisition with spatial encoding in a Cartesian system. A drawback of these sequences is their high sensitivity against small perturbations of the magnetic field, caused, e.g., by differences in magnetic susceptibility of soft tissue, bone and air. The resulting magnetic field inhomogeneities thus cause geometrical distortions and intensity modulations in diffusion-weighted images. This complicates the fusion with anatomical T1- or T2-weighted MR images obtained with conventional spin- or gradient-echo images and negligible distortion. In order to limit the degradation of diffusion-weighted MR data, we present here a variational approach based on a reference scan pair with reversed polarity of the phase- and frequency-encoding gradients and hence reversed distortion. The key novelty is a tailored nonlinear regularization functional to obtain smooth and diffeomorphic transformations. We incorporate the physical distortion model into a variational image registration framework and derive an accurate and fast correction algorithm. We evaluate the applicability of our approach to distorted DTI brain scans of six healthy volunteers. For all datasets, the automatic correction algorithm considerably reduced the image degradation. We show that, after correction, fusion with T1- or T2-weighted images can be obtained by a simple rigid registration. Furthermore, we demonstrate the improvement due to the novel regularization scheme. Most importantly, we show that it provides meaningful, i.e. diffeomorphic, geometric transformations, independent of the actual choice of the regularization parameters.