Image-guided radiotherapy has the potential to increase the success of treatment by decreasing uncertainties concerning tumour position and shape. We pursue integrated diagnostic quality MRI functionality with radiotherapy systems to boost the possibilities of image guidance by providing images with superior soft-tissue contrast during treatment. However, the use of MR images in radiotherapy can be hindered by geometrical distortions due to magnetic field inhomogeneity problems. A method for fast correction of these distortions is presented and implemented. Using a 20 cm square phantom containing a regular grid, a measure of residual deformation after correction is established. At very low gradient strength (which leads to large deformations) a maximum displacement of 2.9 mm is shown to be reduced to 0.63 mm. Next, the method is applied in vivo to the case of pelvic body contour extraction for prostate radiotherapy treatment planning. Here, again with low gradient strengths, distortions of up to 6 mm can be reduced to 2 mm. All results are provided within a lag time of 8 ms. We discuss implications of image distortions for MRI-guided photon and proton radiotherapy separately, since the dose-depth curves in these treatments are very different. We argue that, although field inhomogeneities cannot be prevented from occurring, distortion correction is not always necessary in practice. This work opens new possibilities for investigating on-line MRI-based plan adaptations and ultimately MRI-based treatment planning.