Motion errors are inevitably introduced when data is acquired and considerably degrade the image quality in terms of geometric resolution, radiometric accuracy and image contrast, especially in high-resolution spotlight synthetic aperture radar (SAR) imagery. In this study, the authors present a novel two-dimensional (2D) autofocus algorithm directly inserted into polar format algorithm, which compensates the envelop error and the phase error sequentially. A coarse error correction is first performed by global positioning system or inertial navigation system in the range-compressed domain, then a new envelop compensation strategy, stage-by-stage approach, is designed, obtaining promising results for removing range cell migration after 2D interpolation. Additionally, a weighed contrast enhancement autofocus algorithm based on spatially variant model is developed to compensate for the residual phase error, which remarkably improves the estimation accuracy. The presented algorithm is very robust to deal with substantial errors over a variety of scenes even in conditions of homogenous areas with no prominent point scatterers and enables the utilisation of fast Fourier transform. The experimental results obtained by the proposed algorithm confirm that the analysis extends well to realistic situations.