SAR interferograms are affected by a strong noise component which often prevents correct phase unwrapping and always impairs the phase reconstruction accuracy. To obtain satisfactory performance, most filtering techniques exploit prior information by means of ad hoc, empirical strategies. In this paper, we recast phase filtering as a Bayesian estimation problem in which the image prior is modeled as a suitable Markov random field, and the filtered phase field is the configuration with maximum a posteriori probability. Assuming the image to be residue free and generally smooth, a two-component MRF model is adopted, where the first component penalizes residues, while the second one penalizes discontinuities. Constrained simulated annealing is then used to find the optimal solution. The experimental analysis shows that, by gradually adjusting the MRF parameters, the algorithm filters out most of the high-frequency noise and, in the limit, eliminates all residues, allowing for a trivial phase unwrapping. Given a limited processing time, the algorithm is still able to eliminate most residues, paving the way for the successful use of any subsequent phase unwrapping technique.