This paper presents a stochastic differential equation (SDE) approach forgeneral-purpose image restoration. The key construction consists in amean-reverting SDE that transforms a high-quality image into a degradedcounterpart as a mean state with fixed Gaussian noise. Then, by simulating thecorresponding reverse-time SDE, we are able to restore the origin of thelow-quality image without relying on any task-specific prior knowledge.Crucially, the proposed mean-reverting SDE has a closed-form solution, allowingus to compute the ground truth time-dependent score and learn it with a neuralnetwork. Moreover, we propose a maximum likelihood objective to learn anoptimal reverse trajectory which stabilizes the training and improves therestoration results. In the experiments, we show that our proposed methodachieves highly competitive performance in quantitative comparisons on imagederaining, deblurring, and denoising, setting a new state-of-the-art on twoderaining datasets. Finally, the general applicability of our approach isfurther demonstrated via qualitative results on image super-resolution,inpainting, and dehazing. Code is available athttps://github.com/Algolzw/image-restoration-sde.